http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --cc 
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index af0de7c,4dd0eb9..9e21d7c
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@@ -1500,9 -1549,10 +1549,9 @@@ public class GridCacheUtils 
  
          cache.setEvictionPolicy(null);
          cache.setSwapEnabled(false);
 -        cache.setQueryIndexEnabled(false);
          cache.setCacheStoreFactory(null);
          cache.setEagerTtl(true);
-         cache.setPreloadMode(SYNC);
+         cache.setRebalanceMode(SYNC);
  
          return cache;
      }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueriesImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --cc 
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 152d88d,da75742..ff7d91b
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@@ -352,11 -348,10 +351,10 @@@ public abstract class GridCacheQueryMan
       * @throws IgniteCheckedException Thrown in case of any errors.
       */
      @SuppressWarnings("SimplifiableIfStatement")
-     public void remove(K key, @Nullable byte[] keyBytes) throws 
IgniteCheckedException {
+     public void remove(Object key) throws IgniteCheckedException {
          assert key != null;
  
 -        if (!cctx.config().isQueryIndexEnabled() && !(key instanceof 
GridCacheInternal))
 +        if (!GridQueryProcessor.isEnabled(cctx.config()) && !(key instanceof 
GridCacheInternal))
              return; // No-op.
  
          if (!enterBusy())

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
----------------------------------------------------------------------
diff --cc 
modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
index 34d8838,07f23ef..30e9f46
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
@@@ -149,10 -150,11 +146,9 @@@ public class VisorCacheConfiguration im
          cfg.startSize = ccfg.getStartSize();
          cfg.tmLookupClsName = ccfg.getTransactionManagerLookupClassName();
          cfg.offHeapMaxMemory = ccfg.getOffHeapMaxMemory();
 -        cfg.maxQryIterCnt = ccfg.getMaximumQueryIteratorCount();
          cfg.maxConcurrentAsyncOps = ccfg.getMaxConcurrentAsyncOperations();
          cfg.memoryMode = ccfg.getMemoryMode();
 -        cfg.indexingSpiName = ccfg.getIndexingSpiName();
          cfg.interceptor = compactClass(ccfg.getInterceptor());
-         cfg.valBytes = ccfg.isStoreValueBytes();
          cfg.typeMeta = VisorCacheTypeMetadata.list(ccfg.getTypeMetadata());
          cfg.statisticsEnabled = ccfg.isStatisticsEnabled();
          cfg.mgmtEnabled = ccfg.isManagementEnabled();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
----------------------------------------------------------------------
diff --cc 
modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
index 8a8cb4a,d5b302e..9a7458e
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
@@@ -113,10 -116,11 +113,10 @@@ public class VisorGridConfiguration imp
          caches = VisorCacheConfiguration.list(ignite, 
c.getCacheConfiguration());
          igfss = VisorIgfsConfiguration.list(c.getFileSystemConfiguration());
          streamers = 
VisorStreamerConfiguration.list(c.getStreamerConfiguration());
-         env = new HashMap<>(getenv());
-         sysProps = getProperties();
+         env = new HashMap<>(System.getenv());
+         sysProps = IgniteSystemProperties.snapshot();
          atomic = VisorAtomicConfiguration.from(c.getAtomicConfiguration());
          txCfg = 
VisorTransactionConfiguration.from(c.getTransactionConfiguration());
 -        qryCfg = VisorQueryConfiguration.from(c.getQueryConfiguration());
  
          return this;
      }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/config/discovery-stress.xml
----------------------------------------------------------------------
diff --cc modules/core/src/test/config/discovery-stress.xml
index b3dc389,96a0e54..0fed4df
--- a/modules/core/src/test/config/discovery-stress.xml
+++ b/modules/core/src/test/config/discovery-stress.xml
@@@ -29,8 -29,9 +29,8 @@@
              <bean class="org.apache.ignite.configuration.CacheConfiguration">
                  <property name="cacheMode" value="PARTITIONED"/>
                  <property name="distributionMode" value="PARTITIONED_ONLY"/>
-                 <property name="preloadMode" value="SYNC"/>
+                 <property name="rebalanceMode" value="SYNC"/>
                  <property name="swapEnabled" value="false"/>
 -                <property name="queryIndexEnabled" value="false"/>
                  <property name="writeSynchronizationMode" value="FULL_ASYNC"/>
  
                  <property name="evictionPolicy">

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/config/example-cache.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/config/igfs-loopback.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/config/igfs-shmem.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerAbstractSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
----------------------------------------------------------------------
diff --cc 
modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
index 664433f,b04ad78..f9ff6b4
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
@@@ -83,7 -83,8 +83,7 @@@ public class GridDiscoveryManagerAliveC
          cCfg.setCacheMode(PARTITIONED);
          cCfg.setBackups(1);
          cCfg.setDistributionMode(NEAR_PARTITIONED);
-         cCfg.setPreloadMode(SYNC);
+         cCfg.setRebalanceMode(SYNC);
 -        cCfg.setQueryIndexEnabled(false);
          cCfg.setWriteSynchronizationMode(FULL_SYNC);
  
          TcpDiscoverySpi disc = new TcpDiscoverySpi();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentTxMultiNodeTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLeakTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMemoryModeSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java
----------------------------------------------------------------------
diff --cc 
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java
index a5086db,44c290f..7b429b2
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheP2PUndeploySelfTest.java
@@@ -82,8 -82,9 +82,8 @@@ public class GridCacheP2PUndeploySelfTe
  
          repCacheCfg.setName("replicated");
          repCacheCfg.setCacheMode(REPLICATED);
-         repCacheCfg.setPreloadMode(mode);
+         repCacheCfg.setRebalanceMode(mode);
          
repCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
 -        repCacheCfg.setQueryIndexEnabled(false);
          repCacheCfg.setAtomicityMode(TRANSACTIONAL);
  
          if (offheap)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java
----------------------------------------------------------------------
diff --cc 
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java
index c95ee13,ad5ed0f..9654842
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java
@@@ -620,8 -620,8 +620,7 @@@ public class GridCachePutAllFailoverSel
  
              cacheCfg.setBackups(backups);
  
-             cacheCfg.setStoreValueBytes(true);
              cacheCfg.setDistributionMode(nearEnabled ? NEAR_PARTITIONED : 
PARTITIONED_ONLY);
 -            cacheCfg.setQueryIndexEnabled(false);
  
              cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
  

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryInternalKeysSelfTest.java
----------------------------------------------------------------------
diff --cc 
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryInternalKeysSelfTest.java
index bba3390,63f9ef9..bc8529e
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryInternalKeysSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryInternalKeysSelfTest.java
@@@ -56,7 -56,8 +56,7 @@@ public class GridCacheQueryInternalKeys
      @Override protected CacheConfiguration cacheConfiguration(String 
gridName) throws Exception {
          CacheConfiguration cc = super.cacheConfiguration(gridName);
  
-         cc.setPreloadMode(SYNC);
 -        cc.setQueryIndexEnabled(false);
+         cc.setRebalanceMode(SYNC);
  
          return cc;
      }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxMultiNodeAbstractTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedHitsAndMissesSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/GridCacheLruNearEvictionPolicySelfTest.java
----------------------------------------------------------------------
diff --cc 
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/GridCacheLruNearEvictionPolicySelfTest.java
index 88c1e18,a4fe557..532a91e
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/GridCacheLruNearEvictionPolicySelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/GridCacheLruNearEvictionPolicySelfTest.java
@@@ -60,9 -60,10 +60,9 @@@ public class GridCacheLruNearEvictionPo
          cc.setCacheMode(PARTITIONED);
          cc.setWriteSynchronizationMode(PRIMARY_SYNC);
          cc.setDistributionMode(NEAR_PARTITIONED);
-         cc.setPreloadMode(SYNC);
+         cc.setRebalanceMode(SYNC);
          cc.setNearEvictionPolicy(new 
CacheLruEvictionPolicy(EVICTION_MAX_SIZE));
          cc.setStartSize(100);
 -        cc.setQueryIndexEnabled(true);
          cc.setBackups(0);
  
          c.setCacheConfiguration(cc);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/GridCacheNearOnlyLruNearEvictionPolicySelfTest.java
----------------------------------------------------------------------
diff --cc 
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/GridCacheNearOnlyLruNearEvictionPolicySelfTest.java
index 0dc6d29,f5dcbc0..c8ac60a
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/GridCacheNearOnlyLruNearEvictionPolicySelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/GridCacheNearOnlyLruNearEvictionPolicySelfTest.java
@@@ -71,9 -71,10 +71,9 @@@ public class GridCacheNearOnlyLruNearEv
          cc.setCacheMode(cacheMode);
          cc.setWriteSynchronizationMode(PRIMARY_SYNC);
          cc.setDistributionMode(cnt == 0 ? NEAR_ONLY : PARTITIONED_ONLY);
-         cc.setPreloadMode(SYNC);
+         cc.setRebalanceMode(SYNC);
          cc.setNearEvictionPolicy(new 
CacheLruEvictionPolicy(EVICTION_MAX_SIZE));
          cc.setStartSize(100);
 -        cc.setQueryIndexEnabled(true);
          cc.setBackups(0);
  
          c.setCacheConfiguration(cc);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsCachePerBlockLruEvictionPolicySelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetricsSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsModesSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsServerManagerIpcEndpointRegistrationAbstractSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
----------------------------------------------------------------------
diff --cc 
modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
index 924bd09,63f5166..07e6892
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
@@@ -133,8 -132,9 +132,8 @@@ public class IgfsSizeSelfTest extends I
          }
  
          
dataCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-         dataCfg.setPreloadMode(SYNC);
+         dataCfg.setRebalanceMode(SYNC);
          dataCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
 -        dataCfg.setQueryIndexEnabled(false);
          dataCfg.setAtomicityMode(TRANSACTIONAL);
  
          CacheConfiguration metaCfg = defaultCacheConfiguration();
@@@ -143,7 -143,8 +142,7 @@@
          metaCfg.setCacheMode(REPLICATED);
  
          
metaCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-         metaCfg.setPreloadMode(SYNC);
+         metaCfg.setRebalanceMode(SYNC);
 -        metaCfg.setQueryIndexEnabled(false);
          metaCfg.setAtomicityMode(TRANSACTIONAL);
  
          TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/IpcSharedMemoryNodeStartup.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/loadtests/colocation/spring-colocation.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java
----------------------------------------------------------------------
diff --cc 
modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java
index fd3eb5a,5e4cbd6..e4326bf
--- 
a/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java
@@@ -101,8 -100,9 +100,8 @@@ public abstract class GridMarshallerAbs
  
          namedCache.setName(CACHE_NAME);
          namedCache.setAtomicityMode(TRANSACTIONAL);
 -        namedCache.setQueryIndexEnabled(true);
  
-         cfg.setMarshaller(new OptimizedMarshaller(false));
+         cfg.setMarshaller(marshaller());
          cfg.setStreamerConfiguration(streamerConfiguration());
          cfg.setCacheConfiguration(new CacheConfiguration(), namedCache);
  

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/core/src/test/webapp/META-INF/ignite-webapp-config.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopSecondaryFileSystemConfigurationTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgfsNearOnlyMultiNodeSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemAbstractSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemClientSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemHandshakeSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemIpcCacheSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemLoggerStateSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemSecondaryModeSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --cc 
modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 1080fa1,180ccb5..0892a6f
--- 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@@ -1077,21 -1195,6 +1077,21 @@@ public class IgniteH2Indexing implement
              throw new IgniteCheckedException(e);
          }
  
 +        if (ctx == null) // This is allowed in some tests.
-             marshaller = new OptimizedMarshaller();
++            marshaller = new JdkMarshaller();
 +        else {
 +            this.ctx = ctx;
 +
 +            nodeId = ctx.localNodeId();
 +            marshaller = ctx.config().getMarshaller();
 +
 +            mapQryExec = new GridMapQueryExecutor();
 +            rdcQryExec = new GridReduceQueryExecutor();
 +
 +            mapQryExec.start(ctx, this);
 +            rdcQryExec.start(ctx, this);
 +        }
 +
  //        registerMBean(gridName, this, GridH2IndexingSpiMBean.class); TODO
      }
  

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --cc 
modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFieldsQuerySelfTest.java
index 6c61531,928a45b..43ebd21
--- 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFieldsQuerySelfTest.java
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFieldsQuerySelfTest.java
@@@ -93,8 -93,16 +93,8 @@@ public abstract class GridCacheAbstract
          cache.setCacheMode(cacheMode());
          cache.setAtomicityMode(atomicityMode());
          
cache.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-         cache.setPreloadMode(SYNC);
+         cache.setRebalanceMode(SYNC);
  
 -        CacheQueryConfiguration qcfg = new CacheQueryConfiguration();
 -
 -        qcfg.setIndexPrimitiveKey(true);
 -        qcfg.setIndexPrimitiveValue(true);
 -        qcfg.setIndexFixedTyping(true);
 -
 -        cache.setQueryConfiguration(qcfg);
 -
          if (cacheMode() == PARTITIONED)
              cache.setBackups(1);
  

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapAndSwapSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridIndexingWithNoopSwapSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
----------------------------------------------------------------------
diff --cc 
modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
index 6ab2fe4,0000000..b19e8f0
mode 100644,000000..100644
--- 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
@@@ -1,1554 -1,0 +1,1554 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one or more
 + * contributor license agreements.  See the NOTICE file distributed with
 + * this work for additional information regarding copyright ownership.
 + * The ASF licenses this file to You under the Apache License, Version 2.0
 + * (the "License"); you may not use this file except in compliance with
 + * the License.  You may obtain a copy of the License at
 + *
 + *      http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing, software
 + * distributed under the License is distributed on an "AS IS" BASIS,
 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 + * See the License for the specific language governing permissions and
 + * limitations under the License.
 + */
 +
 +package org.apache.ignite.internal.processors.cache;
 +
 +import org.apache.ignite.*;
 +import org.apache.ignite.cache.*;
 +import org.apache.ignite.cache.query.*;
 +import org.apache.ignite.cache.query.annotations.*;
 +import org.apache.ignite.cache.store.*;
 +import org.apache.ignite.configuration.*;
 +import org.apache.ignite.events.*;
 +import org.apache.ignite.internal.*;
 +import org.apache.ignite.internal.processors.cache.distributed.replicated.*;
 +import org.apache.ignite.internal.processors.cache.query.*;
 +import org.apache.ignite.internal.util.tostring.*;
 +import org.apache.ignite.internal.util.typedef.*;
 +import org.apache.ignite.internal.util.typedef.internal.*;
 +import org.apache.ignite.lang.*;
 +import org.apache.ignite.marshaller.optimized.*;
 +import org.apache.ignite.spi.discovery.tcp.*;
 +import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 +import org.apache.ignite.spi.swapspace.file.*;
 +import org.apache.ignite.testframework.*;
 +import org.apache.ignite.testframework.junits.common.*;
 +import org.jdk8.backport.*;
 +import org.jetbrains.annotations.*;
 +
 +import javax.cache.*;
 +import javax.cache.configuration.*;
 +import javax.cache.expiry.*;
 +import java.io.*;
 +import java.util.*;
 +import java.util.concurrent.*;
 +
 +import static java.util.concurrent.TimeUnit.*;
 +import static org.apache.ignite.cache.CacheAtomicityMode.*;
 +import static org.apache.ignite.cache.CacheDistributionMode.*;
 +import static org.apache.ignite.cache.CacheMode.*;
- import static org.apache.ignite.cache.CachePreloadMode.*;
++import static org.apache.ignite.cache.CacheRebalanceMode.*;
 +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
 +import static org.apache.ignite.events.EventType.*;
 +import static 
org.apache.ignite.internal.processors.cache.query.CacheQueryType.*;
 +import static org.junit.Assert.*;
 +
 +/**
 + * Various tests for cache queries.
 + */
 +public abstract class IgniteCacheAbstractQuerySelfTest extends 
GridCommonAbstractTest {
 +    /** Cache store. */
 +    private static TestStore store = new TestStore();
 +
 +    /** */
 +    private static final TcpDiscoveryIpFinder ipFinder = new 
TcpDiscoveryVmIpFinder(true);
 +
 +    /** */
 +    protected Ignite ignite;
 +
 +    /**
 +     * @return Grid count.
 +     */
 +    protected abstract int gridCount();
 +
 +    /**
 +     * @return Cache mode.
 +     */
 +    protected abstract CacheMode cacheMode();
 +
 +    /**
 +     * @return Atomicity mode.
 +     */
 +    protected CacheAtomicityMode atomicityMode() {
 +        return TRANSACTIONAL;
 +    }
 +
 +    /**
 +     * @return Distribution.
 +     */
 +    protected CacheDistributionMode distributionMode() {
 +        return NEAR_PARTITIONED;
 +    }
 +
 +    /** {@inheritDoc} */
 +    @SuppressWarnings("unchecked")
 +    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
 +        IgniteConfiguration c = super.getConfiguration(gridName);
 +
 +        TcpDiscoverySpi disco = new TcpDiscoverySpi();
 +
 +        disco.setIpFinder(ipFinder);
 +
 +        c.setDiscoverySpi(disco);
 +
 +        // Otherwise noop swap space will be chosen on Windows.
 +        c.setSwapSpaceSpi(new FileSwapSpaceSpi());
 +
 +        c.setMarshaller(new OptimizedMarshaller(false));
 +
 +        CacheConfiguration[] ccs = new CacheConfiguration[2];
 +
 +        for (int i = 0; i < ccs.length; i++) {
 +            CacheConfiguration cc = defaultCacheConfiguration();
 +
 +            if (i > 0)
 +                cc.setName("c" + i);
 +
 +            cc.setCacheMode(cacheMode());
 +            cc.setAtomicityMode(atomicityMode());
 +            cc.setDistributionMode(gridName.startsWith("client") ? 
CLIENT_ONLY : distributionMode());
 +            cc.setWriteSynchronizationMode(FULL_SYNC);
 +            cc.setCacheStoreFactory(new 
FactoryBuilder.SingletonFactory(store));
 +            cc.setReadThrough(true);
 +            cc.setWriteThrough(true);
 +            cc.setLoadPreviousValue(true);
-             cc.setPreloadMode(SYNC);
++            cc.setRebalanceMode(SYNC);
 +            cc.setSwapEnabled(true);
 +            cc.setEvictNearSynchronized(false);
 +            cc.setSqlFunctionClasses(SqlFunctions.class);
 +            cc.setIndexedTypes(
 +                BadHashKeyObject.class, Byte.class,
 +                ObjectValue.class, Long.class,
 +                Integer.class, Integer.class,
 +                Integer.class, String.class,
 +                Integer.class, ObjectValue.class,
 +                String.class, ObjectValueOther.class,
 +                Integer.class, ArrayObject.class,
 +                Key.class, GridCacheQueryTestValue.class,
 +                UUID.class, Person.class,
 +                IgniteCacheReplicatedQuerySelfTest.CacheKey.class, 
IgniteCacheReplicatedQuerySelfTest.CacheValue.class
 +            );
 +
 +            // Explicitly set number of backups equal to number of grids.
 +            if (cacheMode() == CacheMode.PARTITIONED)
 +                cc.setBackups(gridCount());
 +
 +            ccs[i] = cc;
 +        }
 +
 +        c.setCacheConfiguration(ccs);
 +
 +        return c;
 +    }
 +
 +    /** {@inheritDoc} */
 +    @Override protected void beforeTest() throws Exception {
 +        ignite = startGridsMultiThreaded(gridCount());
 +    }
 +
 +    /** {@inheritDoc} */
 +    @Override protected void afterTest() throws Exception {
 +        stopAllGrids();
 +
 +        store.reset();
 +
 +        ignite = null;
 +    }
 +
 +    /**
 +     * JUnit.
 +     *
 +     * @throws Exception In case of error.
 +     */
 +    public void testDifferentKeyTypes() throws Exception {
 +        final IgniteCache<Object, Object> cache = ignite.jcache(null);
 +
 +        cache.put(1, "value");
 +
 +        try {
 +            cache.put("key", "value");
 +
 +            fail();
 +        }
 +        catch (CacheException e) {
 +            // No-op.
 +        }
 +    }
 +
 +    /**
 +     * JUnit.
 +     *
 +     * @throws Exception In case of error.
 +     */
 +    public void testDifferentValueTypes() throws Exception {
 +        GridCache<Integer, Object> cache = ((IgniteKernal)ignite).cache(null);
 +
 +        cache.putx(7, "value");
 +
 +        // Put value of different type but for the same key type.
 +        // Operation should succeed but with warning log message.
 +        cache.putx(7, 1);
 +    }
 +
 +    /**
 +     * JUnit.
 +     *
 +     * @throws Exception In case of error.
 +     */
 +    public void testStringType() throws Exception {
 +        IgniteCache<Integer, String> cache = ignite.jcache(null);
 +
 +        cache.put(666, "test");
 +
 +        QueryCursor<Cache.Entry<Integer, String>> qry = cache.query(new 
SqlQuery(String.class, "_val='test'"));
 +
 +        Cache.Entry<Integer, String> entry = F.first(qry.getAll());
 +
 +        assert entry != null;
 +        assertEquals(666, entry.getKey().intValue());
 +    }
 +
 +    /**
 +     * JUnit.
 +     *
 +     * @throws Exception In case of error.
 +     */
 +    public void testIntegerType() throws Exception {
 +        IgniteCache<Integer, Integer> cache = ignite.jcache(null);
 +
 +        int key = 898;
 +
 +        int val = 2;
 +
 +        cache.put(key, val);
 +
 +        QueryCursor<Cache.Entry<Integer, Integer>> qry =
 +            cache.query(new SqlQuery(Integer.class, "_key = ? and _val > 
1").setArgs(key));
 +
 +        Cache.Entry<Integer, Integer> entry = F.first(qry.getAll());
 +
 +        assert entry != null;
 +
 +        assertEquals(key, entry.getKey().intValue());
 +        assertEquals(val, entry.getValue().intValue());
 +    }
 +
 +    /**
 +     * Tests UDFs.
 +     *
 +     * @throws IgniteCheckedException If failed.
 +     */
 +    public void testUserDefinedFunction() throws IgniteCheckedException {
 +        // Without alias.
 +        final IgniteCache<Object, Object> cache = ignite.jcache(null);
 +
 +        QueryCursor<List<?>> qry = cache.queryFields(new 
SqlFieldsQuery("select square(1), square(2)"));
 +
 +        Collection<List<?>> res = qry.getAll();
 +
 +        if (cacheMode() == REPLICATED)
 +            assertEquals(1, res.size());
 +        else
 +            assertEquals(gridCount(), res.size());
 +
 +        List<?> row = res.iterator().next();
 +
 +        assertEquals(1, row.get(0));
 +        assertEquals(4, row.get(1));
 +
 +        // With alias.
 +        qry = cache.queryFields(new SqlFieldsQuery("select _cube_(1), 
_cube_(2)"));
 +
 +        res = qry.getAll();
 +
 +        if (cacheMode() == REPLICATED)
 +            assertEquals(1, res.size());
 +        else
 +            assertEquals(gridCount(), res.size());
 +
 +        row = res.iterator().next();
 +
 +        assertEquals(1, row.get(0));
 +        assertEquals(8, row.get(1));
 +
 +        // Not registered.
 +        GridTestUtils.assertThrows(
 +            log,
 +            new Callable<Object>() {
 +                @Override public Object call() throws Exception {
 +                    cache.queryFields(new SqlFieldsQuery("select no()"));
 +
 +                    return null;
 +                }
 +            },
 +            CacheException.class,
 +            null
 +        );
 +    }
 +
 +    /**
 +     * Expired entries are not included to result.
 +     *
 +     * @throws Exception If failed.
 +     */
 +    public void testExpiration() throws Exception {
 +        ignite.jcache(null).
 +            withExpiryPolicy(new TouchedExpiryPolicy(new 
Duration(MILLISECONDS, 1000))).put(7, 1);
 +
 +        IgniteCache<Integer, Integer> cache = ignite.jcache(null);
 +
 +        List<Cache.Entry<Integer, Integer>> qry = cache.query(new 
SqlQuery(Integer.class, "1=1")).getAll();
 +
 +        Cache.Entry<Integer, Integer> res = F.first(qry);
 +
 +        assertEquals(1, res.getValue().intValue());
 +
 +        U.sleep(1020);
 +
 +        qry = cache.query(new SqlQuery(Integer.class, "1=1")).getAll();
 +
 +        res = F.first(qry);
 +
 +        assertNull(res);
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    public void testIllegalBounds() throws Exception {
 +        IgniteCache<Integer, Integer> cache = ignite.jcache(null);
 +
 +        cache.put(1, 1);
 +        cache.put(2, 2);
 +
 +        QueryCursor<Cache.Entry<Integer,Integer>> qry = cache.query(new 
SqlQuery(Integer.class, "_key between 2 and 1"));
 +
 +        assertTrue(qry.getAll().isEmpty());
 +    }
 +
 +    /**
 +     * JUnit.
 +     *
 +     * @throws Exception In case of error.
 +     */
 +    public void testComplexType() throws Exception {
 +        IgniteCache<Key, GridCacheQueryTestValue> cache = ignite.jcache(null);
 +
 +        GridCacheQueryTestValue val1 = new GridCacheQueryTestValue();
 +
 +        val1.setField1("field1");
 +        val1.setField2(1);
 +        val1.setField3(1L);
 +
 +        GridCacheQueryTestValue val2 = new GridCacheQueryTestValue();
 +
 +        val2.setField1("field2");
 +        val2.setField2(2);
 +        val2.setField3(2L);
 +        val2.setField6(null);
 +
 +        cache.put(new Key(100500), val1);
 +        cache.put(new Key(100501), val2);
 +
 +        QueryCursor<Cache.Entry<Key, GridCacheQueryTestValue>> qry = cache
 +            .query(new SqlQuery(GridCacheQueryTestValue.class,
 +                    "fieldName='field1' and field2=1 and field3=1 and 
id=100500 and embeddedField2=11 and x=3"));
 +
 +        Cache.Entry<Key, GridCacheQueryTestValue> entry = 
F.first(qry.getAll());
 +
 +        assertNotNull(entry);
 +        assertEquals(100500, entry.getKey().id);
 +        assertEquals(val1, entry.getValue());
 +    }
 +
 +    /**
 +     * Complex key type.
 +     */
 +    private static class Key {
 +        /** */
 +        @QuerySqlField
 +        private final long id;
 +
 +        /**
 +         * @param id Id.
 +         */
 +        private Key(long id) {
 +            this.id = id;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public boolean equals(Object o) {
 +            if (this == o)
 +                return true;
 +
 +            if (o == null || getClass() != o.getClass())
 +                return false;
 +
 +            Key key = (Key)o;
 +
 +            return id == key.id;
 +
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public int hashCode() {
 +            return (int)(id ^ (id >>> 32));
 +        }
 +    }
 +
 +    /**
 +     * JUnit.
 +     *
 +     * @throws Exception In case of error.
 +     */
 +    public void testSelectQuery() throws Exception {
 +        IgniteCache<Integer, String> cache = ignite.jcache(null);
 +
 +        cache.put(10, "value");
 +
 +        QueryCursor<Cache.Entry<Integer, String>> qry = cache.query(new 
SqlQuery(String.class, "true"));
 +
 +        Iterator<Cache.Entry<Integer, String>> iter = qry.iterator();
 +
 +        assert iter != null;
 +        assert iter.next() != null;
 +    }
 +
 +    /**
 +     * JUnit.
 +     *
 +     * @throws Exception In case of error.
 +     */
 +    public void testObjectQuery() throws Exception {
 +        IgniteCache<Integer, ObjectValue> cache = ignite.jcache(null);
 +
 +        ObjectValue val = new ObjectValue("test", 0);
 +
 +        cache.put(1, val);
 +
 +        QueryCursor<Cache.Entry<Integer, ObjectValue>> qry =
 +            cache.query(new SqlQuery(ObjectValue.class, 
"_val=?").setArgs(val));
 +
 +        Iterator<Cache.Entry<Integer, ObjectValue>> iter = qry.iterator();
 +
 +        assert iter != null;
 +
 +        int expCnt = 1;
 +
 +        for (int i = 0; i < expCnt; i++)
 +            assert iter.next() != null;
 +
 +        assert !iter.hasNext();
 +
 +        qry = cache.query(new TextQuery(ObjectValue.class, "test"));
 +
 +        iter = qry.iterator();
 +
 +        assert iter != null;
 +
 +        for (int i = 0; i < expCnt; i++)
 +            assert iter.next() != null;
 +
 +        assert !iter.hasNext();
 +    }
 +
 +    /**
 +     * JUnit.
 +     *
 +     * @throws Exception In case of error.
 +     */
 +    public void testObjectQueryWithSwap() throws Exception {
 +        IgniteCache<Integer, ObjectValue> cache = ignite.jcache(null);
 +
 +        boolean partitioned = 
cache.getConfiguration(CacheConfiguration.class).getCacheMode() == PARTITIONED;
 +
 +        int cnt = 10;
 +
 +        for (int i = 0; i < cnt; i++)
 +            cache.put(i, new ObjectValue("test" + i, i));
 +
 +        for (Ignite g : G.allGrids()) {
 +            GridCache<Integer, ObjectValue> c = ((IgniteKernal)g).cache(null);
 +
 +            for (int i = 0; i < cnt; i++) {
 +                if (i % 2 == 0) {
 +                    assertNotNull(c.peek(i));
 +
 +                    c.evict(i); // Swap.
 +
 +                    if (!partitioned || 
c.affinity().mapKeyToNode(i).isLocal()) {
 +                        ObjectValue peekVal = c.peek(i);
 +
 +                        assertNull("Non-null value for peek [key=" + i + ", 
val=" + peekVal + ']', peekVal);
 +                    }
 +                }
 +            }
 +        }
 +
 +
 +        QueryCursor<Cache.Entry<Integer, ObjectValue>> qry =
 +            cache.query(new SqlQuery(ObjectValue.class, "intVal >= ? order by 
intVal").setArgs(0));
 +
 +        Iterator<Cache.Entry<Integer, ObjectValue>> iter = qry.iterator();
 +
 +        assert iter != null;
 +
 +        Collection<Integer> set = new HashSet<>(cnt);
 +
 +        Cache.Entry<Integer, ObjectValue> next;
 +
 +        while (iter.hasNext()) {
 +            next = iter.next();
 +            
 +            ObjectValue v = next.getValue();
 +
 +            assert !set.contains(v.intValue());
 +
 +            set.add(v.intValue());
 +        }
 +
 +        assert !iter.hasNext();
 +
 +        assertEquals(cnt, set.size());
 +
 +        for (int i = 0; i < cnt; i++)
 +            assert set.contains(i);
 +
 +        qry = cache.query(new SqlQuery(ObjectValue.class, "MOD(intVal, 2) = ? 
order by intVal").setArgs(0));
 +
 +        iter = qry.iterator();
 +
 +        assert iter != null;
 +
 +        set.clear();
 +
 +        while (iter.hasNext()) {
 +            next = iter.next();
 +
 +            ObjectValue v = next.getValue();
 +
 +            assert !set.contains(v.intValue());
 +
 +            set.add(v.intValue());
 +        }
 +
 +        assert !iter.hasNext();
 +
 +        assertEquals(cnt / 2, set.size());
 +
 +        for (int i = 0; i < cnt; i++)
 +            if (i % 2 == 0)
 +                assert set.contains(i);
 +            else
 +                assert !set.contains(i);
 +    }
 +
 +    /**
 +     * JUnit.
 +     *
 +     * @throws Exception In case of error.
 +     */
 +    public void testFullTextSearch() throws Exception {
 +        IgniteCache<Integer, ObjectValue> cache = ignite.jcache(null);
 +
 +        // Try to execute on empty cache first.
 +        QueryCursor<Cache.Entry<Integer, ObjectValue>> qry =
 +            cache.query(new TextQuery(ObjectValue.class, "full"));
 +
 +        assert qry.getAll().isEmpty();
 +
 +        qry = cache.query(new TextQuery(ObjectValue.class, "full"));
 +
 +        assert qry.getAll().isEmpty();
 +
 +        // Now put indexed values into cache.
 +        int key1 = 1;
 +
 +        ObjectValue val1 = new ObjectValue("test full text", 0);
 +
 +        cache.put(key1, val1);
 +
 +        int key2 = 2;
 +
 +        ObjectValue val2 = new ObjectValue("test full text more", 0);
 +
 +        cache.put(key2, val2);
 +
 +        qry = cache.query(new TextQuery(ObjectValue.class, "full"));
 +
 +        Collection<Cache.Entry<Integer, ObjectValue>> res = qry.getAll();
 +
 +        assert res != null;
 +
 +        assert res.size() == 2;
 +
 +        qry = cache.query(new TextQuery(ObjectValue.class, "full"));
 +
 +        res = qry.getAll();
 +
 +        assert res != null;
 +        assert res.size() == 2;
 +    }
 +
 +    /**
 +     * JUnit.
 +     *
 +     * @throws Exception In case of error.
 +     */
 +    public void testScanQuery() throws Exception {
 +        IgniteCache<Integer, String> c1 = ignite.jcache(null);
 +
 +        c1.put(777, "value");
 +
 +        // Scan query.
 +        QueryCursor<Cache.Entry<Integer, String>> qry = c1.query(new 
ScanQuery<String, String>());
 +
 +        Iterator<Cache.Entry<Integer, String>> iter = qry.iterator();
 +
 +        assert iter != null;
 +
 +        int expCnt = 1;
 +
 +        for (int i = 0; i < expCnt; i++) {
 +            Cache.Entry<Integer, String> e1 = iter.next();
 +
 +            assertEquals(777, e1.getKey().intValue());
 +            assertEquals("value", e1.getValue());
 +        }
 +
 +        assert !iter.hasNext();
 +    }
 +
 +    /**
 +     * JUnit.
 +     *
 +     * @throws Exception In case of error.
 +     */
 +    public void testTwoObjectsTextSearch() throws Exception {
 +        IgniteCache<Object, Object> c = ignite.jcache(null);
 +
 +        c.put(1, new ObjectValue("ObjectValue str", 1));
 +        c.put("key", new ObjectValueOther("ObjectValueOther str"));
 +
 +        Collection<Cache.Entry<Object, Object>> res = c.query(new 
TextQuery(ObjectValue.class, "str")).getAll();
 +
 +        assert res != null;
 +        int expCnt = 1;
 +        assert res.size() == expCnt;
 +        assert F.first(res).getValue().getClass() == ObjectValue.class;
 +
 +        res = c.query(new TextQuery(ObjectValueOther.class, "str")).getAll();
 +
 +        assert res != null;
 +        assert res.size() == expCnt;
 +        assert F.first(res).getValue().getClass() == ObjectValueOther.class;
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    public void testEmptyObject() throws Exception {
 +        IgniteCache<EmptyObject, EmptyObject> cache = ignite.jcache(null);
 +
 +        cache.put(new EmptyObject(1), new EmptyObject(2));
 +
 +        for (int i = 0; i < gridCount(); i++) {
 +            GridCacheQueryManager<Object, Object> qryMgr =
 +                ((IgniteKernal)grid(i)).internalCache().context().queries();
 +
 +            assert !hasIndexTable(EmptyObject.class, qryMgr);
 +        }
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    public void testPrimitiveType() throws Exception {
 +        IgniteCache<Integer, Integer> cache = ignite.jcache(null);
 +
 +        cache.put(1, 1);
 +        cache.put(2, 2);
 +
 +        QueryCursor<Cache.Entry<Integer, Integer>> q = cache.query(new 
SqlQuery(Integer.class, "_val > 1"));
 +
 +        Collection<Cache.Entry<Integer, Integer>> res = q.getAll();
 +
 +        assertEquals(1, res.size());
 +
 +        for (Cache.Entry<Integer, Integer> e : res) {
 +            assertEquals(2, (int)e.getKey());
 +            assertEquals(2, (int)e.getValue());
 +        }
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    public void testPaginationIteratorDefaultCache() throws Exception {
 +        testPaginationIterator(null);
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    public void testPaginationIteratorNamedCache() throws Exception {
 +        testPaginationIterator("c1");
 +    }
 +
 +    /**
 +     * @param cacheName Cache name.
 +     * @throws Exception If failed.
 +     */
 +    private void testPaginationIterator(@Nullable String cacheName) throws 
Exception {
 +        IgniteCache<Integer, Integer> cache = ignite.jcache(cacheName);
 +
 +        for (int i = 0; i < 50; i++)
 +            cache.put(i, i);
 +
 +        SqlQuery qry = new SqlQuery(Integer.class, "_key >= 0");
 +
 +        qry.setPageSize(10);
 +
 +        QueryCursor<Cache.Entry<Integer, Integer>> q = cache.query(qry);
 +
 +        int cnt = 0;
 +
 +        for (Cache.Entry<Integer, Integer> e : q) {
 +            assertTrue(e.getKey() >= 0 && e.getKey() < 50);
 +            assertTrue(e.getValue() >= 0 && e.getValue() < 50);
 +
 +            cnt++;
 +        }
 +
 +        assertEquals(50, cnt);
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    public void testPaginationGetDefaultCache() throws Exception {
 +        testPaginationGet(null);
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    public void testPaginationGetNamedCache() throws Exception {
 +        testPaginationGet("c1");
 +    }
 +
 +    /**
 +     * @param cacheName Cache name.
 +     * @throws Exception If failed.
 +     */
 +    private void testPaginationGet(@Nullable String cacheName) throws 
Exception {
 +        IgniteCache<Integer, Integer> cache = ignite.jcache(cacheName);
 +
 +        for (int i = 0; i < 50; i++)
 +            cache.put(i, i);
 +
 +        QueryCursor<Cache.Entry<Integer, Integer>> q =
 +            cache.query(new SqlQuery(Integer.class, "_key >= 0"));
 +
 +        List<Cache.Entry<Integer, Integer>> list = new 
ArrayList<>(q.getAll());
 +
 +        Collections.sort(list, new Comparator<Cache.Entry<Integer, 
Integer>>() {
 +            @Override public int compare(Cache.Entry<Integer, Integer> e1, 
Cache.Entry<Integer, Integer> e2) {
 +                return e1.getKey().compareTo(e2.getKey());
 +            }
 +        });
 +
 +        for (int i = 0; i < 50; i++) {
 +            Cache.Entry<Integer, Integer> e = list.get(i);
 +
 +            assertEquals(i, (int)e.getKey());
 +            assertEquals(i, (int)e.getValue());
 +        }
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    public void testScanFilters() throws Exception {
 +        IgniteCache<Integer, Integer> cache = ignite.jcache(null);
 +
 +        for (int i = 0; i < 50; i++)
 +            cache.put(i, i);
 +
 +        QueryCursor<Cache.Entry<Integer, Integer>> q = cache.query(new 
ScanQuery(new IgniteBiPredicate<Integer,Integer>() {
 +            @Override public boolean apply(Integer k, Integer v) {
 +                assertNotNull(k);
 +                assertNotNull(v);
 +
 +                return k >= 20 && v < 40;
 +            }
 +        }));
 +
 +        List<Cache.Entry<Integer, Integer>> list = new 
ArrayList<>(q.getAll());
 +
 +        Collections.sort(list, new Comparator<Cache.Entry<Integer, 
Integer>>() {
 +            @Override public int compare(Cache.Entry<Integer, Integer> e1, 
Cache.Entry<Integer, Integer> e2) {
 +                return e1.getKey().compareTo(e2.getKey());
 +            }
 +        });
 +
 +        assertEquals(20, list.size());
 +
 +        for (int i = 20; i < 40; i++) {
 +            Cache.Entry<Integer, Integer> e = list.get(i - 20);
 +
 +            assertEquals(i, (int)e.getKey());
 +            assertEquals(i, (int)e.getValue());
 +        }
 +    }
 +
 +    /**
 +     * @throws IgniteCheckedException if failed.
 +     */
 +    public void testBadHashObjectKey() throws IgniteCheckedException {
 +        IgniteCache<BadHashKeyObject, Byte> cache = ignite.jcache(null);
 +
 +        cache.put(new BadHashKeyObject("test_key1"), (byte)1);
 +        cache.put(new BadHashKeyObject("test_key0"), (byte)10);
 +        cache.put(new BadHashKeyObject("test_key1"), (byte)7);
 +
 +        assertEquals(10, cache.query(new SqlQuery(Byte.class, "_key = 
?").setArgs(
 +            new 
BadHashKeyObject("test_key0"))).getAll().get(0).getValue().intValue());
 +    }
 +
 +    /**
 +     * @throws IgniteCheckedException if failed.
 +     */
 +    public void testTextIndexedKey() throws IgniteCheckedException {
 +        IgniteCache<ObjectValue, Long> cache = ignite.jcache(null);
 +
 +        cache.put(new ObjectValue("test_key1", 10), 19L);
 +        cache.put(new ObjectValue("test_key0", 11), 11005L);
 +        cache.put(new ObjectValue("test_key1", 12), 17L);
 +
 +        assertEquals(11005L,
 +            cache.query(new TextQuery(Long.class, "test_key0"))
 +                .getAll().get(0).getValue().intValue());
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    public void testOrderByOnly() throws Exception {
 +        IgniteCache<Integer, Integer> cache = ignite.jcache(null);
 +
 +        for (int i = 0; i < 10; i++)
 +            cache.put(i, i);
 +
 +        QueryCursor<Cache.Entry<Integer, Integer>> q =
 +            cache.query(new SqlQuery(Integer.class, "_key >= 0"));
 +
 +        Collection<Cache.Entry<Integer, Integer>> res = q.getAll();
 +
 +        assertEquals(10, res.size());
 +
 +        if (cacheMode() != PARTITIONED) {
 +            Iterator<Cache.Entry<Integer, Integer>> it = res.iterator();
 +
 +            for (Integer i = 0; i < 10; i++) {
 +                assertTrue(it.hasNext());
 +
 +                Cache.Entry<Integer, Integer> e = it.next();
 +
 +                assertEquals(i, e.getKey());
 +                assertEquals(i, e.getValue());
 +            }
 +        }
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    public void testLimitOnly() throws Exception {
 +        IgniteCache<Integer, Integer> cache = ignite.jcache(null);
 +
 +        for (int i = 0; i < 10; i++)
 +            cache.put(i, i);
 +
 +        QueryCursor<Cache.Entry<Integer, Integer>> q =
 +                cache.query(new SqlQuery(Integer.class, "limit 5"));
 +
 +        Collection<Cache.Entry<Integer, Integer>> res = q.getAll();
 +
 +        assertEquals(5, res.size());
 +
 +        Set<Integer> checkDuplicate = new HashSet<>();
 +
 +        for (Cache.Entry<Integer, Integer> e : res) {
 +            assert e.getKey() < 10 && e.getKey() >= 0;
 +            assert e.getValue() < 10 && e.getValue() >= 0;
 +
 +            checkDuplicate.add(e.getValue());
 +        }
 +
 +        assertEquals(5, checkDuplicate.size());
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    public void testArray() throws Exception {
 +        IgniteCache<Integer, ArrayObject> cache = ignite.jcache(null);
 +
 +        cache.put(1, new ArrayObject(new Long[]{1L, null, 3L}));
 +        cache.put(2, new ArrayObject(new Long[] {4L, 5L, 6L}));
 +
 +        QueryCursor<Cache.Entry<Integer, ArrayObject>> q =
 +            cache.query(new SqlQuery(ArrayObject.class, "array_contains(arr, 
cast(? as long))").setArgs(4));
 +
 +        Collection<Cache.Entry<Integer, ArrayObject>> res = q.getAll();
 +
 +        assertEquals(1, res.size());
 +
 +        Cache.Entry<Integer, ArrayObject> e = F.first(res);
 +
 +        assertEquals(2, (int)e.getKey());
 +        assertArrayEquals(new Long[]{4L, 5L, 6L}, e.getValue().arr);
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    public void testSqlQueryEvents() throws Exception {
 +        checkSqlQueryEvents();
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    private void checkSqlQueryEvents() throws Exception {
 +        final CountDownLatch execLatch = new CountDownLatch(cacheMode() == 
REPLICATED ? 1 : gridCount());
 +
 +        for (int i = 0; i < gridCount(); i++) {
 +            grid(i).events().localListen(new IgnitePredicate<Event>() {
 +                @Override public boolean apply(Event evt) {
 +                    assert evt instanceof CacheQueryExecutedEvent;
 +
 +                    CacheQueryExecutedEvent qe = (CacheQueryExecutedEvent)evt;
 +
 +                    assertNull(qe.cacheName());
 +                    assertNotNull(qe.clause());
 +                    assertNull(qe.scanQueryFilter());
 +                    assertNull(qe.continuousQueryFilter());
 +                    assertArrayEquals(new Integer[] { 10 }, qe.arguments());
 +
 +                    execLatch.countDown();
 +
 +                    return true;
 +                }
 +            }, EVT_CACHE_QUERY_EXECUTED);
 +        }
 +
 +        IgniteCache<Integer, Integer> cache = ignite.jcache(null);
 +
 +        for (int i = 0; i < 20; i++)
 +            cache.put(i, i);
 +
 +        QueryCursor<Cache.Entry<Integer, Integer>> q =
 +            cache.query(new SqlQuery(Integer.class, "_key >= ?").setArgs(10));
 +
 +        q.getAll();
 +
 +        assert execLatch.await(1000, MILLISECONDS);
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    public void testScanQueryEvents() throws Exception {
 +        checkScanQueryEvents();
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    private void checkScanQueryEvents() throws Exception {
 +        final Map<Integer, Integer> map = new ConcurrentHashMap8<>();
 +        final CountDownLatch latch = new CountDownLatch(10);
 +        final CountDownLatch execLatch = new CountDownLatch(cacheMode() == 
REPLICATED ? 1 : gridCount());
 +
 +        for (int i = 0; i < gridCount(); i++) {
 +            grid(i).events().localListen(new IgnitePredicate<Event>() {
 +                @Override public boolean apply(Event evt) {
 +                    assert evt instanceof CacheQueryReadEvent;
 +
 +                    CacheQueryReadEvent<Integer, Integer> qe = 
(CacheQueryReadEvent<Integer, Integer>)evt;
 +
 +                    assertEquals(SCAN, qe.queryType());
 +                    assertNull(qe.cacheName());
 +
 +                    assertNull(qe.className());
 +                    assertNull(null, qe.clause());
 +                    assertNotNull(qe.scanQueryFilter());
 +                    assertNull(qe.continuousQueryFilter());
 +                    assertNull(qe.arguments());
 +
 +                    map.put(qe.key(), qe.value());
 +
 +                    latch.countDown();
 +
 +                    return true;
 +                }
 +            }, EVT_CACHE_QUERY_OBJECT_READ);
 +
 +            grid(i).events().localListen(new IgnitePredicate<Event>() {
 +                @Override public boolean apply(Event evt) {
 +                    assert evt instanceof CacheQueryExecutedEvent;
 +
 +                    CacheQueryExecutedEvent qe = (CacheQueryExecutedEvent)evt;
 +
 +                    assertEquals(SCAN, qe.queryType());
 +                    assertNull(qe.cacheName());
 +
 +                    assertNull(qe.className());
 +                    assertNull(null, qe.clause());
 +                    assertNotNull(qe.scanQueryFilter());
 +                    assertNull(qe.continuousQueryFilter());
 +                    assertNull(qe.arguments());
 +
 +                    execLatch.countDown();
 +
 +                    return true;
 +                }
 +            }, EVT_CACHE_QUERY_EXECUTED);
 +        }
 +
 +        IgniteCache<Integer, Integer> cache = ignite.jcache(null);
 +
 +        for (int i = 0; i < 20; i++)
 +            cache.put(i, i);
 +
 +        QueryCursor<Cache.Entry<Integer, Integer>> q = cache.query(new 
ScanQuery<>(new IgniteBiPredicate<Integer,Integer>() {
 +            @Override public boolean apply(Integer k, Integer v) {
 +                return k >= 10;
 +            }
 +        }));
 +
 +        q.getAll();
 +
 +        assert latch.await(1000, MILLISECONDS);
 +        assert execLatch.await(1000, MILLISECONDS);
 +
 +        assertEquals(10, map.size());
 +
 +        for (int i = 10; i < 20; i++)
 +            assertEquals(i, map.get(i).intValue());
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    public void testTextQueryEvents() throws Exception {
 +        testTextQueryEvents(false);
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    private void testTextQueryEvents(final boolean customSubjId) throws 
Exception {
 +        final Map<Integer, Person> map = new ConcurrentHashMap8<>();
 +        final CountDownLatch latch = new CountDownLatch(2);
 +        final CountDownLatch execLatch = new CountDownLatch(cacheMode() == 
REPLICATED ? 1 : gridCount());
 +
 +        for (int i = 0; i < gridCount(); i++) {
 +            grid(i).events().localListen(new IgnitePredicate<Event>() {
 +                @Override public boolean apply(Event evt) {
 +                    assert evt instanceof CacheQueryReadEvent;
 +
 +                    CacheQueryReadEvent<Integer, Person> qe = 
(CacheQueryReadEvent<Integer, Person>)evt;
 +
 +                    assertEquals(FULL_TEXT, qe.queryType());
 +                    assertNull(qe.cacheName());
 +
 +                    assertEquals("Person", qe.className());
 +                    assertEquals("White", qe.clause());
 +                    assertNull(qe.scanQueryFilter());
 +                    assertNull(qe.continuousQueryFilter());
 +                    assertNull(qe.arguments());
 +
 +                    map.put(qe.key(), qe.value());
 +
 +                    latch.countDown();
 +
 +                    return true;
 +                }
 +            }, EVT_CACHE_QUERY_OBJECT_READ);
 +
 +            grid(i).events().localListen(new IgnitePredicate<Event>() {
 +                @Override public boolean apply(Event evt) {
 +                    assert evt instanceof CacheQueryExecutedEvent;
 +
 +                    CacheQueryExecutedEvent qe = (CacheQueryExecutedEvent)evt;
 +
 +                    assertEquals(FULL_TEXT, qe.queryType());
 +                    assertNull(qe.cacheName());
 +
 +                    assertEquals("Person", qe.className());
 +                    assertEquals("White", qe.clause());
 +                    assertNull(qe.scanQueryFilter());
 +                    assertNull(qe.continuousQueryFilter());
 +                    assertNull(qe.arguments());
 +
 +                    execLatch.countDown();
 +
 +                    return true;
 +                }
 +            }, EVT_CACHE_QUERY_EXECUTED);
 +        }
 +
 +        IgniteCache<Integer, Person> cache = ignite.jcache(null);
 +
 +        cache.put(1, new Person("Bob White", 1000));
 +        cache.put(2, new Person("Tom White", 1000));
 +        cache.put(3, new Person("Mike Green", 1000));
 +
 +
 +        QueryCursor<Cache.Entry<Integer, Person>> q = cache.query(new 
TextQuery(Person.class, "White"));
 +
 +        q.getAll();
 +
 +        assert latch.await(1000, MILLISECONDS);
 +        assert execLatch.await(1000, MILLISECONDS);
 +
 +        assertEquals(2, map.size());
 +
 +        assertEquals("Bob White", map.get(1).name());
 +        assertEquals("Tom White", map.get(2).name());
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    public void testFieldsQueryEvents() throws Exception {
 +        checkFieldsQueryEvents();
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    private void checkFieldsQueryEvents() throws Exception {
 +        final CountDownLatch execLatch = new CountDownLatch(cacheMode() == 
REPLICATED ? 1 : gridCount());
 +
 +        for (int i = 0; i < gridCount(); i++) {
 +            grid(i).events().localListen(new IgnitePredicate<Event>() {
 +                @Override public boolean apply(Event evt) {
 +                    assert evt instanceof CacheQueryExecutedEvent;
 +
 +                    CacheQueryExecutedEvent qe = (CacheQueryExecutedEvent)evt;
 +
 +                    assertNull(qe.cacheName());
 +                    assertNotNull(qe.clause());
 +                    assertNull(qe.scanQueryFilter());
 +                    assertNull(qe.continuousQueryFilter());
 +                    assertArrayEquals(new Integer[]{10}, qe.arguments());
 +
 +                    execLatch.countDown();
 +
 +                    return true;
 +                }
 +            }, EVT_CACHE_QUERY_EXECUTED);
 +        }
 +
 +        IgniteCache<Integer, Person> cache = ignite.jcache(null);
 +
 +        for (int i = 1; i <= 20; i++)
 +            cache.put(i, new Person("Person " + i, i));
 +
 +        QueryCursor<List<?>> q = cache
 +            .queryFields(new SqlFieldsQuery("select _key, name from Person 
where salary > ?").setArgs(10));
 +
 +        q.getAll();
 +
 +        assert execLatch.await(1000, MILLISECONDS);
 +    }
 +
 +    /**
 +     * @param cls Class to check index table for.
 +     * @param qryMgr Query manager.
 +     * @return {@code true} if index has a table for given class.
 +     * @throws IgniteCheckedException If failed.
 +     */
 +    private boolean hasIndexTable(Class<?> cls, GridCacheQueryManager<Object, 
Object> qryMgr) throws IgniteCheckedException {
 +        return qryMgr.size(cls) != -1;
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class ArrayObject implements Serializable {
 +        /** */
 +        @QuerySqlField
 +        private Long[] arr;
 +
 +        /**
 +         * @param arr Array.
 +         */
 +        private ArrayObject(Long[] arr) {
 +            this.arr = arr;
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    public static class Person implements Externalizable {
 +        /** */
 +        @GridToStringExclude
 +        @QuerySqlField
 +        private UUID id = UUID.randomUUID();
 +
 +        /** */
 +        @QuerySqlField
 +        @QueryTextField
 +        private String name;
 +
 +        /** */
 +        @QuerySqlField
 +        private int salary;
 +
 +        /** */
 +        @QuerySqlField(index = true)
 +        private int fake$Field;
 +
 +        /**
 +         * Required by {@link Externalizable}.
 +         */
 +        public Person() {
 +            // No-op.
 +        }
 +
 +        /**
 +         * @param name Name.
 +         * @param salary Salary.
 +         */
 +        public Person(String name, int salary) {
 +            assert name != null;
 +            assert salary > 0;
 +
 +            this.name = name;
 +            this.salary = salary;
 +        }
 +
 +        /**
 +         * @return Id.
 +         */
 +        public UUID id() {
 +            return id;
 +        }
 +
 +        /**
 +         * @return Name.
 +         */
 +        public String name() {
 +            return name;
 +        }
 +
 +        /**
 +         * @return Salary.
 +         */
 +        public double salary() {
 +            return salary;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public void writeExternal(ObjectOutput out) throws 
IOException {
 +            U.writeUuid(out, id);
 +            U.writeString(out, name);
 +            out.writeInt(salary);
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public void readExternal(ObjectInput in) throws 
IOException, ClassNotFoundException {
 +            id = U.readUuid(in);
 +            name = U.readString(in);
 +            salary = in.readInt();
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public int hashCode() {
 +            return id.hashCode() + 31 * name.hashCode() + 31 * 31 * salary;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public boolean equals(Object obj) {
 +            if (obj == this)
 +                return true;
 +
 +            if (!(obj instanceof Person))
 +                return false;
 +
 +            Person that = (Person)obj;
 +
 +            return that.id.equals(id) && that.name.equals(name) && 
that.salary == salary;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public String toString() {
 +            return S.toString(Person.class, this);
 +        }
 +    }
 +
 +    /**
 +     * Test value object.
 +     */
 +    @SuppressWarnings("PublicInnerClass")
 +    public static class ObjectValue implements Serializable {
 +        /** String value. */
 +        @QueryTextField
 +        private String strVal;
 +
 +        /** Integer value. */
 +        @QuerySqlField
 +        private int intVal;
 +
 +        /**
 +         * Constructor.
 +         *
 +         * @param strVal String value.
 +         * @param intVal Integer value.
 +         */
 +        ObjectValue(String strVal, int intVal) {
 +            this.strVal = strVal;
 +            this.intVal = intVal;
 +        }
 +
 +        /**
 +         * Gets value.
 +         *
 +         * @return Value.
 +         */
 +        public String getStringValue() {
 +            return strVal;
 +        }
 +
 +        /**
 +         * @return Integer value.
 +         */
 +        public int intValue() {
 +            return intVal;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public boolean equals(Object o) {
 +            if (this == o)
 +                return true;
 +
 +            if (o == null || getClass() != o.getClass())
 +                return false;
 +
 +            ObjectValue other = (ObjectValue)o;
 +
 +            return strVal == null ? other.strVal == null : 
strVal.equals(other.strVal);
 +
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public int hashCode() {
 +            return strVal != null ? strVal.hashCode() : 0;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public String toString() {
 +            return S.toString(ObjectValue.class, this);
 +        }
 +    }
 +
 +    /**
 +     * Another test value object.
 +     */
 +    private static class ObjectValueOther {
 +        /** Value. */
 +        @QueryTextField
 +        private String val;
 +
 +        /**
 +         * @param val String value.
 +         */
 +        ObjectValueOther(String val) {
 +            this.val = val;
 +        }
 +
 +        /**
 +         * Gets value.
 +         *
 +         * @return Value.
 +         */
 +        public String value() {
 +            return val;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public boolean equals(Object o) {
 +            if (this == o)
 +                return true;
 +
 +            if (o == null || getClass() != o.getClass())
 +                return false;
 +
 +            ObjectValueOther other = (ObjectValueOther)o;
 +
 +            return val == null ? other.val == null : val.equals(other.val);
 +
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public int hashCode() {
 +            return val != null ? val.hashCode() : 0;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public String toString() {
 +            return S.toString(ObjectValueOther.class, this);
 +        }
 +    }
 +
 +    /**
 +     * Empty test object.
 +     */
 +    @SuppressWarnings("UnusedDeclaration")
 +    private static class EmptyObject {
 +        /** */
 +        private int val;
 +
 +        /**
 +         * @param val Value.
 +         */
 +        private EmptyObject(int val) {
 +            this.val = val;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public int hashCode() {
 +            return val;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public boolean equals(Object o) {
 +            if (this == o)
 +                return true;
 +
 +            if (!(o instanceof EmptyObject))
 +                return false;
 +
 +            EmptyObject that = (EmptyObject)o;
 +
 +            return val == that.val;
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class BadHashKeyObject implements Serializable {
 +        /** */
 +        @QuerySqlField(index = false)
 +        private final String str;
 +
 +        /**
 +         * @param str String.
 +         */
 +        private BadHashKeyObject(String str) {
 +            this.str = str;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public boolean equals(Object o) {
 +            if (this == o) return true;
 +            if (o == null || getClass() != o.getClass()) return false;
 +
 +            BadHashKeyObject keyObj = (BadHashKeyObject) o;
 +
 +            return str.equals(keyObj.str);
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public int hashCode() {
 +            return 10;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public String toString() {
 +            return S.toString(BadHashKeyObject.class, this);
 +        }
 +    }
 +
 +    /**
 +     * Test store.
 +     */
 +    private static class TestStore extends CacheStoreAdapter<Object, Object> {
 +        /** */
 +        private Map<Object, Object> map = new ConcurrentHashMap<>();
 +
 +        /** */
 +        void reset() {
 +            map.clear();
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public Object load(Object key) {
 +            return map.get(key);
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public void write(javax.cache.Cache.Entry<? extends Object, 
? extends Object> e) {
 +            map.put(e.getKey(), e.getValue());
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public void delete(Object key) {
 +            map.remove(key);
 +        }
 +    }
 +
 +    /**
 +     * Functions for test.
 +     */
 +    @SuppressWarnings("PublicInnerClass")
 +    public static class SqlFunctions {
 +        /**
 +         * @param x Argument.
 +         * @return Square of given value.
 +         */
 +        @QuerySqlFunction
 +        public static int square(int x) {
 +            return x * x;
 +        }
 +
 +        /**
 +         * @param x Argument.
 +         * @return Cube of given value.
 +         */
 +        @QuerySqlFunction(alias = "_cube_")
 +        public static int cube(int x) {
 +            return x * x * x;
 +        }
 +
 +        /**
 +         * Method which should not be registered.
 +         * @return Nothing.
 +         */
 +        public static int no() {
 +            throw new IllegalStateException();
 +        }
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c4e3222/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePartitionedQueryMultiThreadedSelfTest.java
----------------------------------------------------------------------
diff --cc 
modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePartitionedQueryMultiThreadedSelfTest.java
index e16bac0,0000000..a90281f
mode 100644,000000..100644
--- 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePartitionedQueryMultiThreadedSelfTest.java
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePartitionedQueryMultiThreadedSelfTest.java
@@@ -1,309 -1,0 +1,309 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one or more
 + * contributor license agreements.  See the NOTICE file distributed with
 + * this work for additional information regarding copyright ownership.
 + * The ASF licenses this file to You under the Apache License, Version 2.0
 + * (the "License"); you may not use this file except in compliance with
 + * the License.  You may obtain a copy of the License at
 + *
 + *      http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing, software
 + * distributed under the License is distributed on an "AS IS" BASIS,
 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 + * See the License for the specific language governing permissions and
 + * limitations under the License.
 + */
 +
 +package org.apache.ignite.internal.processors.cache;
 +
 +import org.apache.ignite.*;
 +import org.apache.ignite.cache.*;
 +import org.apache.ignite.cache.query.*;
 +import org.apache.ignite.cache.query.annotations.*;
 +import org.apache.ignite.configuration.*;
 +import org.apache.ignite.internal.*;
 +import org.apache.ignite.internal.util.tostring.*;
 +import org.apache.ignite.internal.util.typedef.*;
 +import org.apache.ignite.internal.util.typedef.internal.*;
 +import org.apache.ignite.spi.discovery.tcp.*;
 +import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 +import org.apache.ignite.testframework.*;
 +import org.apache.ignite.testframework.junits.common.*;
 +
 +import javax.cache.*;
 +import java.io.*;
 +import java.util.*;
 +import java.util.concurrent.atomic.*;
 +
 +import static org.apache.ignite.cache.CacheAtomicityMode.*;
 +import static org.apache.ignite.cache.CacheDistributionMode.*;
 +import static org.apache.ignite.cache.CacheMode.*;
 +
 +/**
 + * Tests for partitioned cache queries.
 + */
 +public class IgniteCachePartitionedQueryMultiThreadedSelfTest extends 
GridCommonAbstractTest {
 +    /** */
 +    private static final boolean TEST_INFO = true;
 +
 +    /** Number of test grids (nodes). Should not be less than 2. */
 +    private static final int GRID_CNT = 3;
 +
 +    /** */
 +    private static TcpDiscoveryIpFinder ipFinder = new 
TcpDiscoveryVmIpFinder(true);
 +
 +    /** Don't start grid by default. */
 +    public IgniteCachePartitionedQueryMultiThreadedSelfTest() {
 +        super(false);
 +    }
 +
 +    /** {@inheritDoc} */
 +    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
 +        IgniteConfiguration c = super.getConfiguration(gridName);
 +
 +        TcpDiscoverySpi disco = new TcpDiscoverySpi();
 +
 +        disco.setIpFinder(ipFinder);
 +
 +        c.setDiscoverySpi(disco);
 +
 +        CacheConfiguration cc = defaultCacheConfiguration();
 +
 +        cc.setCacheMode(PARTITIONED);
 +
 +        // Query should be executed without ongoing transactions.
 +        
cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
 +        cc.setBackups(0);
-         cc.setPreloadMode(CachePreloadMode.SYNC);
++        cc.setRebalanceMode(CacheRebalanceMode.SYNC);
 +        cc.setAtomicityMode(TRANSACTIONAL);
 +        cc.setDistributionMode(NEAR_PARTITIONED);
 +        cc.setIndexedTypes(
 +            UUID.class, Person.class
 +        );
 +
 +        c.setCacheConfiguration(cc);
 +
 +        return c;
 +    }
 +
 +    /** {@inheritDoc} */
 +    @Override protected void beforeTestsStarted() throws Exception {
 +        assert GRID_CNT >= 2 : "Constant GRID_CNT must be greater than or 
equal to 2.";
 +
 +        startGridsMultiThreaded(GRID_CNT);
 +    }
 +
 +    /** {@inheritDoc} */
 +    @Override protected void afterTestsStopped() throws Exception {
 +        stopAllGrids();
 +    }
 +
 +    /** {@inheritDoc} */
 +    @Override protected void afterTest() throws Exception {
 +        super.afterTest();
 +
 +        // Clean up all caches.
 +        for (int i = 0; i < GRID_CNT; i++)
 +            grid(i).jcache(null).removeAll();
 +    }
 +
 +    /** {@inheritDoc} */
 +    @Override protected void info(String msg) {
 +        if (TEST_INFO)
 +            super.info(msg);
 +    }
 +
 +    /**
 +     * JUnit.
 +     *
 +     * @throws Exception If failed.
 +     */
 +    @SuppressWarnings({"TooBroadScope"})
 +    public void testLuceneAndSqlMultithreaded() throws Exception {
 +        // ---------- Test parameters ---------- //
 +        int luceneThreads = 10;
 +        int sqlThreads = 10;
 +        long duration = 10 * 1000;
 +        final int logMod = 100;
 +
 +        final Person p1 = new Person("Jon", 1500, "Master");
 +        final Person p2 = new Person("Jane", 2000, "Master");
 +        final Person p3 = new Person("Mike", 1800, "Bachelor");
 +        final Person p4 = new Person("Bob", 1900, "Bachelor");
 +
 +        final IgniteCache<UUID, Person> cache0 = grid(0).jcache(null);
 +
 +        cache0.put(p1.id(), p1);
 +        cache0.put(p2.id(), p2);
 +        cache0.put(p3.id(), p3);
 +        cache0.put(p4.id(), p4);
 +
 +        assertEquals(4, cache0.localSize());
 +
 +        assert grid(0).cluster().nodes().size() == GRID_CNT;
 +
 +        final AtomicBoolean done = new AtomicBoolean();
 +
 +        final AtomicLong luceneCnt = new AtomicLong();
 +
 +        // Start lucene query threads.
 +        IgniteInternalFuture<?> futLucene = 
GridTestUtils.runMultiThreadedAsync(new CAX() {
 +            @Override public void applyx() throws IgniteCheckedException {
 +                while (!done.get()) {
 +                    QueryCursor<Cache.Entry<UUID, Person>> master =
 +                        cache0.query(new TextQuery(Person.class, "Master"));
 +
 +                    Collection<Cache.Entry<UUID, Person>> entries = 
master.getAll();
 +
 +                    checkResult(entries, p1, p2);
 +
 +                    long cnt = luceneCnt.incrementAndGet();
 +
 +                    if (cnt % logMod == 0)
 +                        info("Executed LUCENE queries: " + cnt);
 +                }
 +            }
 +        }, luceneThreads, "LUCENE-THREAD");
 +
 +        final AtomicLong sqlCnt = new AtomicLong();
 +
 +        // Start sql query threads.
 +        IgniteInternalFuture<?> futSql = 
GridTestUtils.runMultiThreadedAsync(new CAX() {
 +            @Override public void applyx() throws IgniteCheckedException {
 +                while (!done.get()) {
 +                    QueryCursor<Cache.Entry<UUID, Person>> bachelors =
 +                            cache0.query(new SqlQuery(Person.class, "degree = 
'Bachelor'"));
 +
 +                    Collection<Cache.Entry<UUID, Person>> entries = 
bachelors.getAll();
 +
 +                    checkResult(entries, p3, p4);
 +
 +                    long cnt = sqlCnt.incrementAndGet();
 +
 +                    if (cnt % logMod == 0)
 +                        info("Executed SQL queries: " + cnt);
 +                }
 +            }
 +        }, sqlThreads, "SQL-THREAD");
 +
 +        Thread.sleep(duration);
 +
 +        done.set(true);
 +
 +        futLucene.get();
 +        futSql.get();
 +    }
 +
 +    /**
 +     * @param entries Queried result.
 +     * @param persons Persons that should be in the result.
 +     */
 +    private void checkResult(Iterable<Cache.Entry<UUID, Person>> entries, 
Person... persons) {
 +        for (Cache.Entry<UUID, Person> entry : entries) {
 +            assertEquals(entry.getKey(), entry.getValue().id());
 +
 +            assert F.asList(persons).contains(entry.getValue());
 +        }
 +    }
 +
 +    /** Test class. */
 +    private static class Person implements Externalizable {
 +        /** */
 +        @GridToStringExclude
 +        private UUID id = UUID.randomUUID();
 +
 +        /** */
 +        @QuerySqlField
 +        private String name;
 +
 +        /** */
 +        @QuerySqlField
 +        private int salary;
 +
 +        /** */
 +        @QuerySqlField
 +        @QueryTextField
 +        private String degree;
 +
 +        /** Required by {@link Externalizable}. */
 +        public Person() {
 +            // No-op.
 +        }
 +
 +        /**
 +         * @param name Name.
 +         * @param salary Salary.
 +         * @param degree Degree.
 +         */
 +        Person(String name, int salary, String degree) {
 +            assert name != null;
 +            assert salary > 0;
 +            assert degree != null;
 +
 +            this.name = name;
 +            this.salary = salary;
 +            this.degree = degree;
 +        }
 +
 +        /** @return Id. */
 +        UUID id() {
 +            return id;
 +        }
 +
 +        /** @return Name. */
 +        String name() {
 +            return name;
 +        }
 +
 +        /** @return Salary. */
 +        double salary() {
 +            return salary;
 +        }
 +
 +        /** @return Degree. */
 +        String degree() {
 +            return degree;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public void writeExternal(ObjectOutput out) throws 
IOException {
 +            U.writeUuid(out, id);
 +            U.writeString(out, name);
 +            out.writeInt(salary);
 +            U.writeString(out, degree);
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public void readExternal(ObjectInput in) throws 
IOException, ClassNotFoundException {
 +            id = U.readUuid(in);
 +            name = U.readString(in);
 +            salary = in.readInt();
 +            degree = U.readString(in);
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public int hashCode() {
 +            return id.hashCode() + 31 * name.hashCode() + 31 * 31 * salary;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public boolean equals(Object obj) {
 +            if (obj == this)
 +                return true;
 +
 +            if (!(obj instanceof Person))
 +                return false;
 +
 +            Person that = (Person)obj;
 +
 +            return that.id.equals(id) && that.name.equals(name) && 
that.salary == salary && that.degree.equals(degree);
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public String toString() {
 +            return S.toString(Person.class, this);
 +        }
 +    }
 +}

Reply via email to