You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by yz...@apache.org on 2015/06/16 17:01:42 UTC

[01/13] incubator-ignite git commit: ignite-745 Fixed query metrics for partitioned cache

Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-960 dd8048bd7 -> 4025ce3c6


ignite-745 Fixed query metrics for partitioned cache


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/1eb3bd24
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/1eb3bd24
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/1eb3bd24

Branch: refs/heads/ignite-960
Commit: 1eb3bd24c50d9c6fdb6de3dedd0216bb6e5a81d8
Parents: f4b1123
Author: agura <ag...@gridgain.com>
Authored: Wed Jun 10 19:23:28 2015 +0300
Committer: agura <ag...@gridgain.com>
Committed: Tue Jun 16 13:38:30 2015 +0300

----------------------------------------------------------------------
 .../processors/query/GridQueryProcessor.java    | 102 ++++++---
 .../CacheAbstractQueryMetricsSelfTest.java      | 205 ++++++++++++++++++
 .../CachePartitionedQueryMetricsSelfTest.java   |  32 +++
 .../CacheReplicatedQueryMetricsSelfTest.java    |  32 +++
 .../cache/GridCacheQueryMetricsSelfTest.java    | 206 -------------------
 .../query/h2/sql/BaseH2CompareQueryTest.java    |   2 +-
 .../IgniteCacheQuerySelfTestSuite.java          |   4 +-
 7 files changed, 344 insertions(+), 239 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1eb3bd24/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 fed90d5..718e6ba 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
@@ -513,8 +513,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      * @throws IgniteCheckedException If failed.
      */
     @SuppressWarnings("unchecked")
-    public <K, V> GridCloseableIterator<IgniteBiTuple<K, V>> query(String space, String clause,
-        Collection<Object> params, String resType, IndexingQueryFilter filters)
+    public <K, V> GridCloseableIterator<IgniteBiTuple<K, V>> query(final String space, final String clause,
+        final Collection<Object> params, final String resType, final IndexingQueryFilter filters)
         throws IgniteCheckedException {
         checkEnabled();
 
@@ -522,12 +522,18 @@ public class GridQueryProcessor extends GridProcessorAdapter {
             throw new IllegalStateException("Failed to execute query (grid is stopping).");
 
         try {
-            TypeDescriptor type = typesByName.get(new TypeName(space, resType));
+            final GridCacheContext<?, ?> cctx = ctx.cache().internalCache(space).context();
 
-            if (type == null || !type.registered())
-                throw new CacheException("Failed to find SQL table for type: " + resType);
+            return executeQuery(cctx, new IgniteOutClosureX<GridCloseableIterator<IgniteBiTuple<K, V>>>() {
+                @Override public GridCloseableIterator<IgniteBiTuple<K, V>> applyx() throws IgniteCheckedException {
+                    TypeDescriptor type = typesByName.get(new TypeName(space, resType));
 
-            return idx.query(space, clause, params, type, filters);
+                    if (type == null || !type.registered())
+                        throw new CacheException("Failed to find SQL table for type: " + resType);
+
+                    return idx.query(space, clause, params, type, filters);
+                }
+            });
         }
         finally {
             busyLock.leaveBusy();
@@ -539,19 +545,26 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      * @param qry Query.
      * @return Cursor.
      */
-    public Iterable<List<?>> queryTwoStep(String space, GridCacheTwoStepQuery qry) {
+    public Iterable<List<?>> queryTwoStep(String space, final GridCacheTwoStepQuery qry) {
         checkxEnabled();
 
         if (!busyLock.enterBusy())
             throw new IllegalStateException("Failed to execute query (grid is stopping).");
 
         try {
-            GridCacheContext<Object, Object> cacheCtx = ctx.cache().internalCache(space).context();
-
-            return idx.queryTwoStep(
-                cacheCtx,
-                qry,
-                cacheCtx.keepPortable());
+            final GridCacheContext<Object, Object> cctx = ctx.cache().internalCache(space).context();
+
+            return executeQuery(cctx, new IgniteOutClosureX<Iterable<List<?>>>() {
+                @Override public Iterable<List<?>> applyx() throws IgniteCheckedException {
+                    return idx.queryTwoStep(
+                        cctx,
+                        qry,
+                        cctx.keepPortable());
+                }
+            });
+        }
+        catch (IgniteCheckedException e) {
+            throw new IgniteException(e);
         }
         finally {
             busyLock.leaveBusy();
@@ -563,14 +576,21 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      * @param qry Query.
      * @return Cursor.
      */
-    public QueryCursor<List<?>> queryTwoStep(GridCacheContext<?,?> cctx, SqlFieldsQuery qry) {
+    public QueryCursor<List<?>> queryTwoStep(final GridCacheContext<?,?> cctx, final SqlFieldsQuery qry) {
         checkxEnabled();
 
         if (!busyLock.enterBusy())
             throw new IllegalStateException("Failed to execute query (grid is stopping).");
 
         try {
-            return idx.queryTwoStep(cctx, qry);
+            return executeQuery(cctx, new IgniteOutClosureX<QueryCursor<List<?>>>() {
+                @Override public QueryCursor<List<?>> applyx() throws IgniteCheckedException {
+                    return idx.queryTwoStep(cctx, qry);
+                }
+            });
+        }
+        catch (IgniteCheckedException e) {
+            throw new IgniteException(e);
         }
         finally {
             busyLock.leaveBusy();
@@ -582,14 +602,21 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      * @param qry Query.
      * @return Cursor.
      */
-    public <K,V> QueryCursor<Cache.Entry<K,V>> queryTwoStep(GridCacheContext<?,?> cctx, SqlQuery qry) {
+    public <K,V> QueryCursor<Cache.Entry<K,V>> queryTwoStep(final GridCacheContext<?,?> cctx, final SqlQuery qry) {
         checkxEnabled();
 
         if (!busyLock.enterBusy())
             throw new IllegalStateException("Failed to execute query (grid is stopping).");
 
         try {
-            return idx.queryTwoStep(cctx, qry);
+            return executeQuery(cctx, new IgniteOutClosureX<QueryCursor<Cache.Entry<K, V>>>() {
+                @Override public QueryCursor<Cache.Entry<K, V>> applyx() throws IgniteCheckedException {
+                    return idx.queryTwoStep(cctx, qry);
+                }
+            });
+        }
+        catch (IgniteCheckedException e) {
+            throw new IgniteException(e);
         }
         finally {
             busyLock.leaveBusy();
@@ -698,7 +725,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
     /**
      * Closeable iterator.
      */
-    private static interface ClIter<X> extends AutoCloseable, Iterator<X> {
+    private interface ClIter<X> extends AutoCloseable, Iterator<X> {
         // No-op.
     }
 
@@ -810,24 +837,30 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      * @throws IgniteCheckedException If failed.
      */
     @SuppressWarnings("unchecked")
-    public <K, V> GridCloseableIterator<IgniteBiTuple<K, V>> queryText(String space, String clause, String resType,
-        IndexingQueryFilter filters) throws IgniteCheckedException {
+    public <K, V> GridCloseableIterator<IgniteBiTuple<K, V>> queryText(final String space, final String clause,
+        final String resType, final IndexingQueryFilter filters) throws IgniteCheckedException {
         checkEnabled();
 
         if (!busyLock.enterBusy())
             throw new IllegalStateException("Failed to execute query (grid is stopping).");
 
         try {
-            TypeDescriptor type = typesByName.get(new TypeName(space, resType));
+            final GridCacheContext<?, ?> cctx = ctx.cache().internalCache(space).context();
 
-            if (type == null || !type.registered())
-                throw new CacheException("Failed to find SQL table for type: " + resType);
+            return executeQuery(cctx, new IgniteOutClosureX<GridCloseableIterator<IgniteBiTuple<K, V>>>() {
+                @Override public GridCloseableIterator<IgniteBiTuple<K, V>> applyx() throws IgniteCheckedException {
+                    TypeDescriptor type = typesByName.get(new TypeName(space, resType));
 
-            return idx.queryText(
-                space,
-                clause,
-                type,
-                filters);
+                    if (type == null || !type.registered())
+                        throw new CacheException("Failed to find SQL table for type: " + resType);
+
+                    return idx.queryText(
+                        space,
+                        clause,
+                        type,
+                        filters);
+                }
+            });
         }
         finally {
             busyLock.leaveBusy();
@@ -842,15 +875,21 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      * @return Field rows.
      * @throws IgniteCheckedException If failed.
      */
-    public GridQueryFieldsResult queryFields(@Nullable String space, String clause, Collection<Object> params,
-        IndexingQueryFilter filters) throws IgniteCheckedException {
+    public GridQueryFieldsResult queryFields(@Nullable final String space, final String clause,
+        final Collection<Object> params, final IndexingQueryFilter filters) throws IgniteCheckedException {
         checkEnabled();
 
         if (!busyLock.enterBusy())
             throw new IllegalStateException("Failed to execute query (grid is stopping).");
 
         try {
-            return idx.queryFields(space, clause, params, filters);
+            final GridCacheContext<?, ?> cctx = ctx.cache().internalCache(space).context();
+
+            return executeQuery(cctx, new IgniteOutClosureX<GridQueryFieldsResult>() {
+                @Override public GridQueryFieldsResult applyx() throws IgniteCheckedException {
+                    return idx.queryFields(space, clause, params, filters);
+                }
+            });
         }
         finally {
             busyLock.leaveBusy();
@@ -1718,6 +1757,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
         }
 
         /** {@inheritDoc} */
+        @SuppressWarnings("unchecked")
         @Override public <T> T value(String field, Object key, Object val) throws IgniteCheckedException {
             assert field != null;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1eb3bd24/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
new file mode 100644
index 0000000..63912bf
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java
@@ -0,0 +1,205 @@
+/*
+ * 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.configuration.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
+
+/**
+ * Tests for cache query metrics.
+ */
+public abstract class CacheAbstractQueryMetricsSelfTest extends GridCommonAbstractTest {
+    /** Grid count. */
+    private static final int GRID_CNT = 2;
+
+    /** Cache mode. */
+    protected CacheMode cacheMode;
+
+    /** */
+    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        startGridsMultiThreaded(GRID_CNT);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setIpFinder(ipFinder);
+
+        cfg.setDiscoverySpi(disco);
+
+        CacheConfiguration<String, Integer> cacheCfg1 = defaultCacheConfiguration();
+
+        cacheCfg1.setName("A");
+        cacheCfg1.setCacheMode(cacheMode);
+        cacheCfg1.setWriteSynchronizationMode(FULL_SYNC);
+        cacheCfg1.setIndexedTypes(String.class, Integer.class);
+
+        CacheConfiguration<String, Integer> cacheCfg2 = defaultCacheConfiguration();
+
+        cacheCfg2.setName("B");
+        cacheCfg2.setCacheMode(cacheMode);
+        cacheCfg2.setWriteSynchronizationMode(FULL_SYNC);
+        cacheCfg2.setIndexedTypes(String.class, Integer.class);
+
+        cfg.setCacheConfiguration(cacheCfg1, cacheCfg2);
+
+        return cfg;
+    }
+
+    /**
+     * Test metrics for SQL queries.
+     *
+     * @throws Exception In case of error.
+     */
+    public void testSqlFieldsQueryMetrics() throws Exception {
+        IgniteCache<String, Integer> cache = grid(0).context().cache().jcache("A");
+
+        // Execute query.
+        SqlFieldsQuery qry = new SqlFieldsQuery("select * from Integer");
+
+        cache.query(qry).getAll();
+
+        QueryMetrics m = cache.queryMetrics();
+
+        assert m != null;
+
+        info("Metrics: " + m);
+
+        assertEquals(1, m.executions());
+        assertEquals(0, m.fails());
+        assertTrue(m.averageTime() >= 0);
+        assertTrue(m.maximumTime() >= 0);
+        assertTrue(m.minimumTime() >= 0);
+
+        // Execute again with the same parameters.
+        cache.query(qry).getAll();
+
+        m = cache.queryMetrics();
+
+        assert m != null;
+
+        info("Metrics: " + m);
+
+        assertEquals(2, m.executions());
+        assertEquals(0, m.fails());
+        assertTrue(m.averageTime() >= 0);
+        assertTrue(m.maximumTime() >= 0);
+        assertTrue(m.minimumTime() >= 0);
+    }
+
+    /**
+     * Test metrics for Scan queries.
+     *
+     * @throws Exception In case of error.
+     */
+    public void testScanQueryMetrics() throws Exception {
+        IgniteCache<String, Integer> cache = grid(0).context().cache().jcache("A");
+
+        // Execute query.
+        ScanQuery<String, Integer> qry = new ScanQuery<>();
+
+        cache.query(qry).getAll();
+
+        QueryMetrics m = cache.queryMetrics();
+
+        assert m != null;
+
+        info("Metrics: " + m);
+
+        assertEquals(1, m.executions());
+        assertEquals(0, m.fails());
+        assertTrue(m.averageTime() >= 0);
+        assertTrue(m.maximumTime() >= 0);
+        assertTrue(m.minimumTime() >= 0);
+
+        // Execute again with the same parameters.
+        cache.query(qry).getAll();
+
+        m = cache.queryMetrics();
+
+        assert m != null;
+
+        info("Metrics: " + m);
+
+        assertEquals(2, m.executions());
+        assertEquals(0, m.fails());
+        assertTrue(m.averageTime() >= 0);
+        assertTrue(m.maximumTime() >= 0);
+        assertTrue(m.minimumTime() >= 0);
+    }
+
+    /**
+     * Test metrics for SQL cross cache queries.
+     *
+     * @throws Exception In case of error.
+     */
+    public void testSqlCrossCacheQueryMetrics() throws Exception {
+        IgniteCache<String, Integer> cache = grid(0).context().cache().jcache("A");
+
+        // Execute query.
+        SqlFieldsQuery qry = new SqlFieldsQuery("select * from \"B\".Integer");
+
+        cache.query(qry).getAll();
+
+        QueryMetrics m = cache.queryMetrics();
+
+        assert m != null;
+
+        info("Metrics: " + m);
+
+        assertEquals(1, m.executions());
+        assertEquals(0, m.fails());
+        assertTrue(m.averageTime() >= 0);
+        assertTrue(m.maximumTime() >= 0);
+        assertTrue(m.minimumTime() >= 0);
+
+        // Execute again with the same parameters.
+        cache.query(qry).getAll();
+
+        m = cache.queryMetrics();
+
+        assert m != null;
+
+        info("Metrics: " + m);
+
+        assertEquals(2, m.executions());
+        assertEquals(0, m.fails());
+        assertTrue(m.averageTime() >= 0);
+        assertTrue(m.maximumTime() >= 0);
+        assertTrue(m.minimumTime() >= 0);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1eb3bd24/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CachePartitionedQueryMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CachePartitionedQueryMetricsSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CachePartitionedQueryMetricsSelfTest.java
new file mode 100644
index 0000000..666acfb
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CachePartitionedQueryMetricsSelfTest.java
@@ -0,0 +1,32 @@
+/*
+ * 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 static org.apache.ignite.cache.CacheMode.*;
+
+/**
+ * Tests for partitioned cache query metrics.
+ */
+public class CachePartitionedQueryMetricsSelfTest extends CacheAbstractQueryMetricsSelfTest {
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        cacheMode = PARTITIONED;
+
+        super.beforeTest();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1eb3bd24/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheReplicatedQueryMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheReplicatedQueryMetricsSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheReplicatedQueryMetricsSelfTest.java
new file mode 100644
index 0000000..2be6dd3
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheReplicatedQueryMetricsSelfTest.java
@@ -0,0 +1,32 @@
+/*
+ * 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 static org.apache.ignite.cache.CacheMode.*;
+
+/**
+ * Tests for replicated cache query metrics.
+ */
+public class CacheReplicatedQueryMetricsSelfTest extends CacheAbstractQueryMetricsSelfTest {
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        cacheMode = REPLICATED;
+
+        super.beforeTest();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1eb3bd24/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryMetricsSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryMetricsSelfTest.java
deleted file mode 100644
index 24011b4..0000000
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryMetricsSelfTest.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.cache.query.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.spi.discovery.tcp.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.apache.ignite.testframework.junits.common.*;
-
-import static org.apache.ignite.cache.CacheMode.*;
-import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
-
-/**
- * Tests for cache query metrics.
- */
-public class GridCacheQueryMetricsSelfTest extends GridCommonAbstractTest {
-    /** */
-    private static final int GRID_CNT = 2;
-
-    /** */
-    private static final CacheMode CACHE_MODE = REPLICATED;
-
-    /** */
-    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        startGridsMultiThreaded(GRID_CNT);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        stopAllGrids();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
-        disco.setIpFinder(ipFinder);
-
-        cfg.setDiscoverySpi(disco);
-
-        CacheConfiguration<String, Integer> cacheCfg1 = defaultCacheConfiguration();
-
-        cacheCfg1.setName("A");
-        cacheCfg1.setCacheMode(CACHE_MODE);
-        cacheCfg1.setWriteSynchronizationMode(FULL_SYNC);
-        cacheCfg1.setIndexedTypes(String.class, Integer.class);
-
-        CacheConfiguration<String, Integer> cacheCfg2 = defaultCacheConfiguration();
-
-        cacheCfg2.setName("B");
-        cacheCfg2.setCacheMode(CACHE_MODE);
-        cacheCfg2.setWriteSynchronizationMode(FULL_SYNC);
-        cacheCfg2.setIndexedTypes(String.class, Integer.class);
-
-        cfg.setCacheConfiguration(cacheCfg1, cacheCfg2);
-
-        return cfg;
-    }
-
-    /**
-     * Test metrics for SQL queries.
-     *
-     * @throws Exception In case of error.
-     */
-    public void testSqlFieldsQueryMetrics() throws Exception {
-        IgniteCache<String, Integer> cache = grid(0).context().cache().jcache("A");
-
-        // Execute query.
-        SqlFieldsQuery qry = new SqlFieldsQuery("select * from Integer");
-
-        cache.query(qry).getAll();
-
-        QueryMetrics m = cache.queryMetrics();
-
-        assert m != null;
-
-        info("Metrics: " + m);
-
-        assertEquals(1, m.executions());
-        assertEquals(0, m.fails());
-        assertTrue(m.averageTime() >= 0);
-        assertTrue(m.maximumTime() >= 0);
-        assertTrue(m.minimumTime() >= 0);
-
-        // Execute again with the same parameters.
-        cache.query(qry).getAll();
-
-        m = cache.queryMetrics();
-
-        assert m != null;
-
-        info("Metrics: " + m);
-
-        assertEquals(2, m.executions());
-        assertEquals(0, m.fails());
-        assertTrue(m.averageTime() >= 0);
-        assertTrue(m.maximumTime() >= 0);
-        assertTrue(m.minimumTime() >= 0);
-    }
-
-    /**
-     * Test metrics for Scan queries.
-     *
-     * @throws Exception In case of error.
-     */
-    public void testScanQueryMetrics() throws Exception {
-        IgniteCache<String, Integer> cache = grid(0).context().cache().jcache("A");
-
-        // Execute query.
-        ScanQuery<String, Integer> qry = new ScanQuery<>();
-
-        cache.query(qry).getAll();
-
-        QueryMetrics m = cache.queryMetrics();
-
-        assert m != null;
-
-        info("Metrics: " + m);
-
-        assertEquals(1, m.executions());
-        assertEquals(0, m.fails());
-        assertTrue(m.averageTime() >= 0);
-        assertTrue(m.maximumTime() >= 0);
-        assertTrue(m.minimumTime() >= 0);
-
-        // Execute again with the same parameters.
-        cache.query(qry).getAll();
-
-        m = cache.queryMetrics();
-
-        assert m != null;
-
-        info("Metrics: " + m);
-
-        assertEquals(2, m.executions());
-        assertEquals(0, m.fails());
-        assertTrue(m.averageTime() >= 0);
-        assertTrue(m.maximumTime() >= 0);
-        assertTrue(m.minimumTime() >= 0);
-    }
-
-    /**
-     * Test metrics for SQL cross cache queries.
-     *
-     * @throws Exception In case of error.
-     */
-    public void testSqlCrossCacheQueryMetrics() throws Exception {
-        IgniteCache<String, Integer> cache = grid(0).context().cache().jcache("A");
-
-        // Execute query.
-        SqlFieldsQuery qry = new SqlFieldsQuery("select * from \"B\".Integer");
-
-        cache.query(qry).getAll();
-
-        QueryMetrics m = cache.queryMetrics();
-
-        assert m != null;
-
-        info("Metrics: " + m);
-
-        assertEquals(1, m.executions());
-        assertEquals(0, m.fails());
-        assertTrue(m.averageTime() >= 0);
-        assertTrue(m.maximumTime() >= 0);
-        assertTrue(m.minimumTime() >= 0);
-
-        // Execute again with the same parameters.
-        cache.query(qry).getAll();
-
-        m = cache.queryMetrics();
-
-        assert m != null;
-
-        info("Metrics: " + m);
-
-        assertEquals(2, m.executions());
-        assertEquals(0, m.fails());
-        assertTrue(m.averageTime() >= 0);
-        assertTrue(m.maximumTime() >= 0);
-        assertTrue(m.minimumTime() >= 0);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1eb3bd24/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
index 9da7cf8..a43f573 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/sql/BaseH2CompareQueryTest.java
@@ -198,8 +198,8 @@ public class BaseH2CompareQueryTest extends AbstractH2CompareQueryTest {
     /**
      * @throws Exception
      */
-    // TODO: IGNITE-705
     public void testAllExamples() throws Exception {
+        fail("https://issues.apache.org/jira/browse/IGNITE-705");
 //        compareQueryRes0("select ? limit ? offset ?");
 
 //        compareQueryRes0("select cool1()");

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1eb3bd24/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
index 0815dc6..e37e696 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
@@ -112,7 +112,9 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
         suite.addTestSuite(BaseH2CompareQueryTest.class);
         suite.addTestSuite(H2CompareBigQueryTest.class);
 
-        suite.addTestSuite(GridCacheQueryMetricsSelfTest.class);
+        // Cache query metrics.
+        suite.addTestSuite(CachePartitionedQueryMetricsSelfTest.class);
+        suite.addTestSuite(CacheReplicatedQueryMetricsSelfTest.class);
 
         //Unmarshallig query test.
         suite.addTestSuite(IgniteCacheP2pUnmarshallingQueryErrorTest.class);


[04/13] incubator-ignite git commit: # ignite-sprint-6 tests fixes

Posted by yz...@apache.org.
# ignite-sprint-6 tests fixes


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/5b9013f6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/5b9013f6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/5b9013f6

Branch: refs/heads/ignite-960
Commit: 5b9013f60af4b86a8d4362890a54d6eaaa159441
Parents: 3423ed3
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jun 16 14:54:23 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jun 16 14:54:23 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/internal/GridSelfTest.java     | 12 +++++++++---
 .../cache/GridCacheAbstractFailoverSelfTest.java     |  2 ++
 ...gniteCacheP2pUnmarshallingRebalanceErrorTest.java | 15 ++++++---------
 .../junits/common/GridCommonAbstractTest.java        | 11 +++++++----
 4 files changed, 24 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5b9013f6/modules/core/src/test/java/org/apache/ignite/internal/GridSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridSelfTest.java
index 7f5ee54..eccae34 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridSelfTest.java
@@ -19,8 +19,10 @@ package org.apache.ignite.internal;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cluster.*;
+import org.apache.ignite.internal.util.lang.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.messaging.*;
+import org.apache.ignite.testframework.*;
 import org.apache.ignite.testframework.junits.common.*;
 
 import java.util.*;
@@ -112,7 +114,7 @@ public class GridSelfTest extends GridProjectionAbstractTest {
     public void testAsyncListen() throws Exception {
         final String msg = "HELLO!";
 
-        Ignite g = grid(0);
+        final Ignite g = grid(0);
 
         final UUID locNodeId = g.cluster().localNode().id();
 
@@ -138,9 +140,13 @@ public class GridSelfTest extends GridProjectionAbstractTest {
 
         g.message().send(null, msg);
 
-        Thread.sleep(1000);
+        GridTestUtils.waitForCondition(new GridAbsPredicate() {
+            @Override public boolean apply() {
+                return cnt.get() == g.cluster().forRemotes().nodes().size();
+            }
+        }, 5000);
 
-        assert cnt.get() == g.cluster().forRemotes().nodes().size();
+        assertEquals(cnt.get(), g.cluster().forRemotes().nodes().size());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5b9013f6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
index 6b7d1b8..b6cd88e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
@@ -68,6 +68,8 @@ public abstract class GridCacheAbstractFailoverSelfTest extends GridCacheAbstrac
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
+        cfg.setNetworkTimeout(60_000);
+
         cfg.getTransactionConfiguration().setTxSerializableEnabled(true);
 
         TcpDiscoverySpi discoSpi = (TcpDiscoverySpi)cfg.getDiscoverySpi();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5b9013f6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingRebalanceErrorTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingRebalanceErrorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingRebalanceErrorTest.java
index 49f58f9..a37f585 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingRebalanceErrorTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingRebalanceErrorTest.java
@@ -34,12 +34,11 @@ public class IgniteCacheP2pUnmarshallingRebalanceErrorTest extends IgniteCacheP2
 
     /** {@inheritDoc} */
     @Override public void testResponseMessageOnUnmarshallingFailed() throws Exception {
-        //GridDhtPartitionSupplyMessage unmarshalling failed test
+        //GridDhtPartitionSupplyMessage unmarshalling failed test.
         readCnt.set(Integer.MAX_VALUE);
 
-        for (int i = 0; i <= 20; i++) {
+        for (int i = 0; i <= 20; i++)
             jcache(0).put(new TestKey(String.valueOf(++key)), "");
-        }
 
         readCnt.set(1);
 
@@ -49,32 +48,30 @@ public class IgniteCacheP2pUnmarshallingRebalanceErrorTest extends IgniteCacheP2
 
         Thread.sleep(1000);
 
-        //GridDhtForceKeysRequest unmarshalling failed test
+        //GridDhtForceKeysRequest unmarshalling failed test.
         stopGrid(3);
 
         readCnt.set(Integer.MAX_VALUE);
 
-        for (int i = 0; i <= 1000; i++) {
+        for (int i = 0; i <= 1000; i++)
             jcache(0).put(new TestKey(String.valueOf(++key)), "");
-        }
 
         startGrid(3);
 
         Affinity<Object> aff = affinity(grid(3).cache(null));
 
-        while (!aff.isPrimary(grid(3).localNode(), new TestKey(String.valueOf(key)))) {
+        while (!aff.isPrimary(grid(3).localNode(), new TestKey(String.valueOf(key))))
             --key;
-        }
 
         readCnt.set(1);
 
         try {
             jcache(3).get(new TestKey(String.valueOf(key)));
+
             assert false : "p2p marshalling failed, but error response was not sent";
         }
         catch (CacheException e) {
             assert X.hasCause(e, IOException.class);
         }
-
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5b9013f6/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index d3535b4..bc33746 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -336,14 +336,14 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
 
     /**
      * @param cnt Count.
-     * @param awaitPartitionMapExchange If we need to await partition map exchange.
+     * @param awaitPartMapExchange If we need to await partition map exchange.
      * @return Ignite.
      * @throws Exception If failed.
      */
-    protected final Ignite startGridsMultiThreaded(int cnt, boolean awaitPartitionMapExchange) throws Exception {
+    protected final Ignite startGridsMultiThreaded(int cnt, boolean awaitPartMapExchange) throws Exception {
         Ignite g = super.startGridsMultiThreaded(cnt);
 
-        if (awaitPartitionMapExchange)
+        if (awaitPartMapExchange)
             awaitPartitionMapExchange();
 
         return g;
@@ -379,7 +379,8 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
 
                             int exp = affNodes.size();
 
-                            Collection<ClusterNode> owners = top.nodes(p, AffinityTopologyVersion.NONE);
+                            Collection<ClusterNode> owners = top.topologyVersion() == AffinityTopologyVersion.NONE ?
+                                Collections.<ClusterNode>emptyList() : top.nodes(p, AffinityTopologyVersion.NONE);
 
                             int actual = owners.size();
 
@@ -388,6 +389,7 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
                                     "grid=" + g.name() +
                                     ", cache=" + cfg.getName() +
                                     ", cacheId=" + dht.context().cacheId() +
+                                    ", topVer=" + top.topologyVersion() +
                                     ", p=" + p +
                                     ", affNodesCnt=" + exp +
                                     ", ownersCnt=" + actual +
@@ -403,6 +405,7 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
                                         "grid=" + g.name() +
                                         ", cache=" + cfg.getName() +
                                         ", cacheId=" + dht.context().cacheId() +
+                                        ", topVer=" + top.topologyVersion() +
                                         ", p=" + p +
                                         ", affNodesCnt=" + exp +
                                         ", ownersCnt=" + actual +


[02/13] incubator-ignite git commit: # ignite-883 client reconnect issues

Posted by yz...@apache.org.
# ignite-883 client reconnect issues


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/54bfa36c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/54bfa36c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/54bfa36c

Branch: refs/heads/ignite-960
Commit: 54bfa36c7417109832effe9c59c0120d9249b1b9
Parents: f4b1123
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jun 16 12:14:20 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jun 16 14:03:03 2015 +0300

----------------------------------------------------------------------
 .../ignite/spi/discovery/tcp/ClientImpl.java    | 87 ++++++++++++++------
 .../distributed/IgniteCacheManyClientsTest.java | 66 +++++++++++----
 2 files changed, 116 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/54bfa36c/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index a17296c..fef6f4f 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -545,14 +545,31 @@ class ClientImpl extends TcpDiscoveryImpl {
      * @param msg Discovery message.
      * @return Latest topology snapshot.
      */
-    private NavigableSet<ClusterNode> updateTopologyHistory(long topVer, @Nullable TcpDiscoveryAbstractMessage msg) {
+    private Collection<ClusterNode> updateTopologyHistory(long topVer, @Nullable TcpDiscoveryAbstractMessage msg) {
         this.topVer = topVer;
 
+        if (!topHist.isEmpty() && topVer <= topHist.lastKey()) {
+            if (log.isDebugEnabled())
+                log.debug("Skip topology update since topology already updated [msg=" + msg +
+                    ", lastHistKey=" + topHist.lastKey() +
+                    ", topVer=" + topVer +
+                    ", locNode=" + locNode + ']');
+
+            Collection<ClusterNode> top = topHist.get(topVer);
+
+            assert top != null : msg;
+
+            return top;
+        }
+
         NavigableSet<ClusterNode> allNodes = allVisibleNodes();
 
         if (!topHist.containsKey(topVer)) {
             assert topHist.isEmpty() || topHist.lastKey() == topVer - 1 :
-                "lastVer=" + topHist.lastKey() + ", newVer=" + topVer + ", locNode=" + locNode + ", msg=" + msg;
+                "lastVer=" + (topHist.isEmpty() ? null : topHist.lastKey()) +
+                ", newVer=" + topVer +
+                ", locNode=" + locNode +
+                ", msg=" + msg;
 
             topHist.put(topVer, allNodes);
 
@@ -886,7 +903,7 @@ class ClientImpl extends TcpDiscoveryImpl {
          * @param join {@code True} if reconnects during join.
          */
         protected Reconnector(boolean join) {
-            super(spi.ignite().name(), "tcp-client-disco-msg-worker", log);
+            super(spi.ignite().name(), "tcp-client-disco-reconnector", log);
 
             this.join = join;
         }
@@ -944,7 +961,8 @@ class ClientImpl extends TcpDiscoveryImpl {
                         sock.setKeepAlive(true);
                         sock.setTcpNoDelay(true);
 
-                        // Wait for
+                        List<TcpDiscoveryAbstractMessage> msgs = null;
+
                         while (!isInterrupted()) {
                             TcpDiscoveryAbstractMessage msg = spi.marsh.unmarshal(in, U.gridClassLoader());
 
@@ -955,12 +973,23 @@ class ClientImpl extends TcpDiscoveryImpl {
                                     if (res.success()) {
                                         msgWorker.addMessage(res);
 
+                                        if (msgs != null) {
+                                            for (TcpDiscoveryAbstractMessage msg0 : msgs)
+                                                msgWorker.addMessage(msg0);
+                                        }
+
                                         success = true;
                                     }
 
                                     return;
                                 }
                             }
+                            else if (spi.ensured(msg)) {
+                                if (msgs == null)
+                                    msgs = new ArrayList<>();
+
+                                msgs.add(msg);
+                            }
                         }
                     }
                     catch (IOException | IgniteCheckedException e) {
@@ -1286,23 +1315,32 @@ class ClientImpl extends TcpDiscoveryImpl {
                     return;
                 }
 
-                if (!topHist.isEmpty() && msg.topologyVersion() <= topHist.lastKey()) {
-                    if (log.isDebugEnabled())
-                        log.debug("Discarding node add finished message since topology already updated " +
-                            "[msg=" + msg + ", lastHistKey=" + topHist.lastKey() + ", node=" + node + ']');
-
-                    return;
-                }
+                boolean evt = false;
 
                 long topVer = msg.topologyVersion();
 
-                node.order(topVer);
-                node.visible(true);
+                assert topVer > 0 : msg;
+
+                if (!node.visible()) {
+                    node.order(topVer);
+                    node.visible(true);
+
+                    if (spi.locNodeVer.equals(node.version()))
+                        node.version(spi.locNodeVer);
+
+                    evt = true;
+                }
+                else {
+                    if (log.isDebugEnabled())
+                        log.debug("Skip node join event, node already joined [msg=" + msg + ", node=" + node + ']');
+
+                    assert node.order() == topVer : node;
+                }
 
-                if (spi.locNodeVer.equals(node.version()))
-                    node.version(spi.locNodeVer);
+                Collection<ClusterNode> top = updateTopologyHistory(topVer, msg);
 
-                NavigableSet<ClusterNode> top = updateTopologyHistory(topVer, msg);
+                assert top != null && top.contains(node) : "Topology does not contain node [msg=" + msg +
+                    ", node=" + node + ", top=" + top + ']';
 
                 if (!pending && joinLatch.getCount() > 0) {
                     if (log.isDebugEnabled())
@@ -1311,9 +1349,11 @@ class ClientImpl extends TcpDiscoveryImpl {
                     return;
                 }
 
-                notifyDiscovery(EVT_NODE_JOINED, topVer, node, top);
+                if (evt) {
+                    notifyDiscovery(EVT_NODE_JOINED, topVer, node, top);
 
-                spi.stats.onNodeJoined();
+                    spi.stats.onNodeJoined();
+                }
             }
         }
 
@@ -1340,7 +1380,7 @@ class ClientImpl extends TcpDiscoveryImpl {
                     return;
                 }
 
-                NavigableSet<ClusterNode> top = updateTopologyHistory(msg.topologyVersion(), msg);
+                Collection<ClusterNode> top = updateTopologyHistory(msg.topologyVersion(), msg);
 
                 if (!pending && joinLatch.getCount() > 0) {
                     if (log.isDebugEnabled())
@@ -1383,7 +1423,7 @@ class ClientImpl extends TcpDiscoveryImpl {
                     return;
                 }
 
-                NavigableSet<ClusterNode> top = updateTopologyHistory(msg.topologyVersion(), msg);
+                Collection<ClusterNode> top = updateTopologyHistory(msg.topologyVersion(), msg);
 
                 if (!pending && joinLatch.getCount() > 0) {
                     if (log.isDebugEnabled())
@@ -1555,7 +1595,7 @@ class ClientImpl extends TcpDiscoveryImpl {
          * @param node Node.
          * @param top Topology snapshot.
          */
-        private void notifyDiscovery(int type, long topVer, ClusterNode node, NavigableSet<ClusterNode> top) {
+        private void notifyDiscovery(int type, long topVer, ClusterNode node, Collection<ClusterNode> top) {
             notifyDiscovery(type, topVer, node, top, null);
         }
 
@@ -1564,8 +1604,9 @@ class ClientImpl extends TcpDiscoveryImpl {
          * @param topVer Topology version.
          * @param node Node.
          * @param top Topology snapshot.
+         * @param data Optional custom message data.
          */
-        private void notifyDiscovery(int type, long topVer, ClusterNode node, NavigableSet<ClusterNode> top,
+        private void notifyDiscovery(int type, long topVer, ClusterNode node, Collection<ClusterNode> top,
             @Nullable DiscoverySpiCustomMessage data) {
             DiscoverySpiListener lsnr = spi.lsnr;
 
@@ -1589,7 +1630,7 @@ class ClientImpl extends TcpDiscoveryImpl {
         }
 
         /**
-         *
+         * @return Queue size.
          */
         public int queueSize() {
             return queue.size();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/54bfa36c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java
index 62c7c1a..947ded2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java
@@ -17,9 +17,11 @@
 
 package org.apache.ignite.internal.processors.cache.distributed;
 
+import junit.framework.*;
 import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.util.lang.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.spi.communication.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.*;
@@ -102,16 +104,14 @@ public class IgniteCacheManyClientsTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
-    public void testManyClients() throws Exception {
+    public void testManyClients() throws Throwable {
         manyClientsPutGet();
     }
 
     /**
      * @throws Exception If failed.
      */
-    public void testManyClientsClientDiscovery() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-883");
-
+    public void testManyClientsClientDiscovery() throws Throwable {
         clientDiscovery = true;
 
         manyClientsPutGet();
@@ -121,8 +121,6 @@ public class IgniteCacheManyClientsTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     public void testManyClientsSequentiallyClientDiscovery() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-883");
-
         clientDiscovery = true;
 
         manyClientsSequentially();
@@ -162,33 +160,48 @@ public class IgniteCacheManyClientsTest extends GridCommonAbstractTest {
 
         log.info("All clients started.");
 
-        assertEquals(SRVS + CLIENTS, G.allGrids().size());
+        checkNodes(SRVS + CLIENTS);
+
+        for (Ignite client : clients)
+            client.close();
+    }
+
+    /**
+     * @param expCnt Expected number of nodes.
+     */
+    private void checkNodes(int expCnt) {
+        assertEquals(expCnt, G.allGrids().size());
 
         long topVer = -1L;
 
         for (Ignite ignite : G.allGrids()) {
-            assertEquals(SRVS + CLIENTS, ignite.cluster().nodes().size());
+            log.info("Check node: " + ignite.name());
 
             if (topVer == -1L)
                 topVer = ignite.cluster().topologyVersion();
             else
-                assertEquals(topVer, ignite.cluster().topologyVersion());
-        }
+                assertEquals("Unexpected topology version for node: " + ignite.name(),
+                    topVer,
+                    ignite.cluster().topologyVersion());
 
-        for (Ignite client : clients)
-            client.close();
+            assertEquals("Unexpected number of nodes for node: " + ignite.name(),
+                expCnt,
+                ignite.cluster().nodes().size());
+        }
     }
 
     /**
      * @throws Exception If failed.
      */
-    private void manyClientsPutGet() throws Exception {
+    private void manyClientsPutGet() throws Throwable {
         client = true;
 
         final AtomicInteger idx = new AtomicInteger(SRVS);
 
         final AtomicBoolean stop = new AtomicBoolean();
 
+        final AtomicReference<Throwable> err = new AtomicReference<>();
+
         final int THREADS = 50;
 
         final CountDownLatch latch = new CountDownLatch(THREADS);
@@ -224,7 +237,7 @@ public class IgniteCacheManyClientsTest extends GridCommonAbstractTest {
 
                             counted = true;
 
-                            while (!stop.get()) {
+                            while (!stop.get() && err.get() == null) {
                                 key = rnd.nextInt(0, 1000);
 
                                 cache.put(key, iter++);
@@ -240,6 +253,8 @@ public class IgniteCacheManyClientsTest extends GridCommonAbstractTest {
                         return null;
                     }
                     catch (Throwable e) {
+                        err.compareAndSet(null, e);
+
                         log.error("Unexpected error in client thread: " + e, e);
 
                         throw e;
@@ -257,6 +272,29 @@ public class IgniteCacheManyClientsTest extends GridCommonAbstractTest {
 
             Thread.sleep(10_000);
 
+            Throwable err0 = err.get();
+
+            if (err0 != null)
+                throw err0;
+
+            boolean wait = GridTestUtils.waitForCondition(new GridAbsPredicate() {
+                @Override public boolean apply() {
+                    try {
+                        checkNodes(SRVS + THREADS);
+
+                        return true;
+                    }
+                    catch (AssertionFailedError e) {
+                        log.info("Check failed, will retry: " + e);
+                    }
+
+                    return false;
+                }
+            }, 10_000);
+
+            if (!wait)
+                checkNodes(SRVS + THREADS);
+
             log.info("Stop clients.");
 
             stop.set(true);


[06/13] incubator-ignite git commit: # ignite-883 fixed test

Posted by yz...@apache.org.
# ignite-883 fixed test


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/22ec5cf2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/22ec5cf2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/22ec5cf2

Branch: refs/heads/ignite-960
Commit: 22ec5cf2a50ac7719ddc25ed5feb7ca06c491931
Parents: 54bfa36
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jun 16 15:58:53 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jun 16 15:58:53 2015 +0300

----------------------------------------------------------------------
 .../IgniteCacheClientNodeConcurrentStart.java         | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/22ec5cf2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeConcurrentStart.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeConcurrentStart.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeConcurrentStart.java
index bd74ece..1eff7fb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeConcurrentStart.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeConcurrentStart.java
@@ -37,7 +37,7 @@ public class IgniteCacheClientNodeConcurrentStart extends GridCommonAbstractTest
     protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
 
     /** */
-    private static final int NODES_CNT = 5;
+    private static final int NODES_CNT = 6;
 
     /** */
     private Set<Integer> clientNodes;
@@ -83,13 +83,21 @@ public class IgniteCacheClientNodeConcurrentStart extends GridCommonAbstractTest
                 clientNodes = new HashSet<>();
 
                 while (clientNodes.size() < 2)
-                    clientNodes.add(rnd.nextInt(0, NODES_CNT));
+                    clientNodes.add(rnd.nextInt(1, NODES_CNT));
 
                 clientNodes.add(NODES_CNT - 1);
 
                 log.info("Test iteration [iter=" + i + ", clients=" + clientNodes + ']');
 
-                startGridsMultiThreaded(NODES_CNT, true);
+                Ignite srv = startGrid(0); // Start server node first.
+
+                assertFalse(srv.configuration().isClientMode());
+
+                startGridsMultiThreaded(1, NODES_CNT - 1);
+
+                checkTopology(NODES_CNT);
+
+                awaitPartitionMapExchange();
 
                 for (int node : clientNodes) {
                     Ignite ignite = grid(node);


[08/13] incubator-ignite git commit: Merge remote-tracking branch 'remotes/origin/ignite-883' into ignite-sprint-6

Posted by yz...@apache.org.
Merge remote-tracking branch 'remotes/origin/ignite-883' into ignite-sprint-6


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/f2c4cc80
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/f2c4cc80
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/f2c4cc80

Branch: refs/heads/ignite-960
Commit: f2c4cc8017fd29adc398f3b98cde361a1156d6a6
Parents: f6b1b79 22ec5cf
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jun 16 16:24:52 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jun 16 16:24:52 2015 +0300

----------------------------------------------------------------------
 .../ignite/spi/discovery/tcp/ClientImpl.java    | 87 ++++++++++++++------
 .../IgniteCacheClientNodeConcurrentStart.java   | 14 +++-
 .../distributed/IgniteCacheManyClientsTest.java | 66 +++++++++++----
 3 files changed, 127 insertions(+), 40 deletions(-)
----------------------------------------------------------------------



[11/13] incubator-ignite git commit: Merge branches 'ignite-960' and 'ignite-sprint-6' of https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-960

Posted by yz...@apache.org.
Merge branches 'ignite-960' and 'ignite-sprint-6' of https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-960


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/ca89d81c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/ca89d81c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/ca89d81c

Branch: refs/heads/ignite-960
Commit: ca89d81c3e271ea2f905698540b67df8a2cab079
Parents: a7ca45b ae188c7
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Tue Jun 16 17:37:34 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Tue Jun 16 17:37:34 2015 +0300

----------------------------------------------------------------------
 .../internal/interop/InteropBootstrap.java      |   3 +-
 .../internal/interop/InteropIgnition.java       |   5 +-
 .../processors/query/GridQueryProcessor.java    | 102 ++++++---
 .../ignite/spi/discovery/tcp/ClientImpl.java    |  87 +++++---
 .../apache/ignite/internal/GridSelfTest.java    |  12 +-
 .../GridDiscoveryManagerAliveCacheSelfTest.java |  17 +-
 .../GridCacheAbstractFailoverSelfTest.java      |   2 +
 ...ridCacheMultinodeUpdateAbstractSelfTest.java |   9 +
 .../cache/GridCacheVersionMultinodeTest.java    |   8 +-
 ...CacheP2pUnmarshallingRebalanceErrorTest.java |  15 +-
 .../IgniteCacheClientNodeConcurrentStart.java   |  14 +-
 .../distributed/IgniteCacheManyClientsTest.java |  69 +++++--
 .../GridCachePartitionedTxSalvageSelfTest.java  |  37 +---
 .../junits/common/GridCommonAbstractTest.java   |  11 +-
 .../IgniteCacheFailoverTestSuite.java           |   8 -
 .../IgniteCacheFailoverTestSuite2.java          |  47 +++++
 .../CacheAbstractQueryMetricsSelfTest.java      | 205 ++++++++++++++++++
 .../CachePartitionedQueryMetricsSelfTest.java   |  32 +++
 .../CacheReplicatedQueryMetricsSelfTest.java    |  32 +++
 .../cache/GridCacheQueryMetricsSelfTest.java    | 206 -------------------
 .../query/h2/sql/BaseH2CompareQueryTest.java    |   2 +-
 .../IgniteCacheQuerySelfTestSuite.java          |   4 +-
 22 files changed, 581 insertions(+), 346 deletions(-)
----------------------------------------------------------------------



[10/13] incubator-ignite git commit: Minor correction to interop start procedure: add optional pointer to additional data required for startup

Posted by yz...@apache.org.
Minor correction to interop start procedure: add optional pointer to additional data required for startup


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/ae188c70
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/ae188c70
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/ae188c70

Branch: refs/heads/ignite-960
Commit: ae188c708854d62fcd586994b83726e8d1db93b1
Parents: e3750b7
Author: ptupitsyn <pt...@gridgain.com>
Authored: Tue Jun 16 17:04:45 2015 +0300
Committer: ptupitsyn <pt...@gridgain.com>
Committed: Tue Jun 16 17:04:45 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/internal/interop/InteropBootstrap.java    | 3 ++-
 .../org/apache/ignite/internal/interop/InteropIgnition.java     | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ae188c70/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrap.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrap.java
index 820bef9..df5af6c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropBootstrap.java
@@ -28,7 +28,8 @@ public interface InteropBootstrap {
      *
      * @param cfg Configuration.
      * @param envPtr Environment pointer.
+     * @param dataPtr Optional pointer to additional data required for startup.
      * @return Ignite node.
      */
-    public InteropProcessor start(IgniteConfiguration cfg, long envPtr);
+    public InteropProcessor start(IgniteConfiguration cfg, long envPtr, long dataPtr);
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ae188c70/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java
index 96639cd..fb0d6e1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java
@@ -45,10 +45,11 @@ public class InteropIgnition {
      * @param gridName Grid name.
      * @param factoryId Factory ID.
      * @param envPtr Environment pointer.
+     * @param dataPtr Optional pointer to additional data required for startup.
      * @return Ignite instance.
      */
     public static synchronized InteropProcessor start(@Nullable String springCfgPath, @Nullable String gridName,
-        int factoryId, long envPtr) {
+        int factoryId, long envPtr, long dataPtr) {
         IgniteConfiguration cfg = configuration(springCfgPath);
 
         if (gridName != null)
@@ -58,7 +59,7 @@ public class InteropIgnition {
 
         InteropBootstrap bootstrap = bootstrap(factoryId);
 
-        InteropProcessor proc = bootstrap.start(cfg, envPtr);
+        InteropProcessor proc = bootstrap.start(cfg, envPtr, dataPtr);
 
         trackFinalization(proc);
 


[09/13] incubator-ignite git commit: # ignite-sprint-6 tests fixes

Posted by yz...@apache.org.
# ignite-sprint-6 tests fixes


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/e3750b78
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/e3750b78
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/e3750b78

Branch: refs/heads/ignite-960
Commit: e3750b78c9fa6b50bee2b35506c706ac4b79126e
Parents: f2c4cc8
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jun 16 16:45:27 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jun 16 16:52:04 2015 +0300

----------------------------------------------------------------------
 .../GridDiscoveryManagerAliveCacheSelfTest.java | 17 ++++++---
 .../distributed/IgniteCacheManyClientsTest.java | 11 +++---
 .../GridCachePartitionedTxSalvageSelfTest.java  | 37 +++-----------------
 3 files changed, 24 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e3750b78/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
----------------------------------------------------------------------
diff --git 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
index ba61890..6e199b8 100644
--- 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
@@ -195,8 +195,11 @@ public class GridDiscoveryManagerAliveCacheSelfTest extends GridCommonAbstractTe
      */
     @SuppressWarnings("SuspiciousMethodCalls")
     private void validateAlives() {
-        for (Ignite g : alive)
-            assertEquals(PERM_NODES_CNT, g.cluster().nodes().size());
+        for (Ignite g : alive) {
+            log.info("Validate node: " + g.name());
+
+            assertEquals("Unexpected nodes number for node: " + g.name(), PERM_NODES_CNT, g.cluster().nodes().size());
+        }
 
         for (final Ignite g : alive) {
             IgniteKernal k = (IgniteKernal)g;
@@ -222,8 +225,14 @@ public class GridDiscoveryManagerAliveCacheSelfTest extends GridCommonAbstractTe
                         }
                     });
 
-                assertTrue(
-                    currTop.contains(GridCacheUtils.oldestAliveCacheServerNode(k.context().cache().context(), new AffinityTopologyVersion(currVer))));
+                GridCacheSharedContext<?, ?> ctx = k.context().cache().context();
+
+                ClusterNode oldest =
+                    GridCacheUtils.oldestAliveCacheServerNode(ctx, new AffinityTopologyVersion(currVer));
+
+                assertNotNull(oldest);
+
+                assertTrue(currTop.contains(oldest));
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e3750b78/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java
index 947ded2..c3223a2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java
@@ -160,10 +160,13 @@ public class IgniteCacheManyClientsTest extends GridCommonAbstractTest {
 
         log.info("All clients started.");
 
-        checkNodes(SRVS + CLIENTS);
-
-        for (Ignite client : clients)
-            client.close();
+        try {
+            checkNodes(SRVS + CLIENTS);
+        }
+        finally {
+            for (Ignite client : clients)
+                client.close();
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e3750b78/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
index 6192f39..c1a19a4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
@@ -21,7 +21,6 @@ import org.apache.ignite.*;
 import org.apache.ignite.cache.affinity.rendezvous.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.cache.transactions.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
@@ -147,8 +146,7 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes
      * Check whether caches has no transactions after salvage timeout.
      *
      * @param mode Transaction mode (PESSIMISTIC, OPTIMISTIC).
-     * @param prepare Whether to prepare transaction state
-     *                (i.e. call {@link IgniteInternalTx#prepare()}).
+     * @param prepare Whether to prepare transaction state (i.e. call {@link IgniteInternalTx#prepare()}).
      * @throws Exception If failed.
      */
     private void checkSalvageAfterTimeout(TransactionConcurrency mode, boolean prepare) throws Exception {
@@ -193,14 +191,13 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes
      * Start new transaction on the grid(0) and put some keys to it.
      *
      * @param mode Transaction mode (PESSIMISTIC, OPTIMISTIC).
-     * @param prepare Whether to prepare transaction state
-     *                (i.e. call {@link IgniteInternalTx#prepare()}).
+     * @param prepare Whether to prepare transaction state (i.e. call {@link IgniteInternalTx#prepare()}).
      * @throws Exception If failed.
      */
     private void startTxAndPutKeys(final TransactionConcurrency mode, final boolean prepare) throws Exception {
         Ignite ignite = grid(0);
 
-        final Collection<Integer> keys = nearKeys(ignite);
+        final Collection<Integer> keys = nearKeys(ignite.cache(null), KEY_CNT, 0);
 
         IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
             @Override public void run() {
@@ -239,31 +236,6 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes
     }
 
     /**
-     * Gets keys that are not primary nor backup for node.
-     *
-     * @param ignite Grid.
-     * @return Collection of keys.
-     */
-    private Collection<Integer> nearKeys(Ignite ignite) {
-        final Collection<Integer> keys = new ArrayList<>(KEY_CNT);
-
-        IgniteKernal kernal = (IgniteKernal) ignite;
-
-        GridCacheAffinityManager affMgr = kernal.internalCache().context().affinity();
-
-        for (int i = 0; i < KEY_CNT * GRID_CNT * 1.5; i++) {
-            if (!affMgr.localNode((Object)i, new AffinityTopologyVersion(kernal.context().discovery().topologyVersion()))) {
-                keys.add(i);
-
-                if (keys.size() == KEY_CNT)
-                    break;
-            }
-        }
-
-        return keys;
-    }
-
-    /**
      * Checks that transaction manager for cache context does not have any pending transactions.
      *
      * @param ctx Cache context.
@@ -283,7 +255,6 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes
     private void checkTxsNotEmpty(GridCacheContext ctx, int exp) {
         int size = ctx.tm().txs().size();
 
-        assert size == exp : "Some transactions were salvaged unexpectedly: " + exp +
-            " expected, but only " + size + " found.";
+        assertEquals("Some transactions were salvaged unexpectedly", exp, size);
     }
 }


[03/13] incubator-ignite git commit: # ignite-sprint-6 moved tests to separate suite

Posted by yz...@apache.org.
# ignite-sprint-6 moved tests to separate suite


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/3423ed36
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/3423ed36
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/3423ed36

Branch: refs/heads/ignite-960
Commit: 3423ed363d4a8fa9539db2e3275cddf03b72812d
Parents: 1eb3bd2
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jun 16 14:28:20 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jun 16 14:28:20 2015 +0300

----------------------------------------------------------------------
 .../IgniteCacheFailoverTestSuite.java           |  8 ----
 .../IgniteCacheFailoverTestSuite2.java          | 47 ++++++++++++++++++++
 2 files changed, 47 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3423ed36/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
index 08178db..dda86c1 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
@@ -65,10 +65,6 @@ public class IgniteCacheFailoverTestSuite extends TestSuite {
         suite.addTestSuite(GridCacheAtomicNearRemoveFailureTest.class);
         suite.addTestSuite(GridCacheAtomicPrimaryWriteOrderNearRemoveFailureTest.class);
 
-        suite.addTestSuite(GridCacheAtomicFailoverSelfTest.class);
-        suite.addTestSuite(GridCacheAtomicPrimaryWriteOrderFailoverSelfTest.class);
-        suite.addTestSuite(GridCacheAtomicReplicatedFailoverSelfTest.class);
-
         suite.addTestSuite(IgniteCacheAtomicNodeJoinTest.class);
         suite.addTestSuite(IgniteCacheTxNodeJoinTest.class);
         suite.addTestSuite(IgniteCacheTxFairAffinityNodeJoinTest.class);
@@ -76,10 +72,6 @@ public class IgniteCacheFailoverTestSuite extends TestSuite {
         suite.addTestSuite(IgniteCacheTxNearDisabledPutGetRestartTest.class);
         suite.addTestSuite(IgniteCacheTxNearDisabledFairAffinityPutGetRestartTest.class);
 
-        suite.addTestSuite(GridCachePartitionedFailoverSelfTest.class);
-        suite.addTestSuite(GridCacheColocatedFailoverSelfTest.class);
-        suite.addTestSuite(GridCacheReplicatedFailoverSelfTest.class);
-
         return suite;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3423ed36/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite2.java
new file mode 100644
index 0000000..3bb4e97
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite2.java
@@ -0,0 +1,47 @@
+/*
+ * 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.testsuites;
+
+import junit.framework.*;
+import org.apache.ignite.internal.processors.cache.distributed.dht.*;
+import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.*;
+import org.apache.ignite.internal.processors.cache.distributed.near.*;
+import org.apache.ignite.internal.processors.cache.distributed.replicated.*;
+
+/**
+ *
+ */
+public class IgniteCacheFailoverTestSuite2 {
+    /**
+     * @return Suite.
+     * @throws Exception If failed.
+     */
+    public static TestSuite suite() throws Exception {
+        TestSuite suite = new TestSuite("Cache Failover Test Suite2");
+
+        suite.addTestSuite(GridCacheAtomicFailoverSelfTest.class);
+        suite.addTestSuite(GridCacheAtomicPrimaryWriteOrderFailoverSelfTest.class);
+        suite.addTestSuite(GridCacheAtomicReplicatedFailoverSelfTest.class);
+
+        suite.addTestSuite(GridCachePartitionedFailoverSelfTest.class);
+        suite.addTestSuite(GridCacheColocatedFailoverSelfTest.class);
+        suite.addTestSuite(GridCacheReplicatedFailoverSelfTest.class);
+
+        return suite;
+    }
+}


[13/13] incubator-ignite git commit: # i-960

Posted by yz...@apache.org.
# i-960


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/4025ce3c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/4025ce3c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/4025ce3c

Branch: refs/heads/ignite-960
Commit: 4025ce3c6e36b95086e434e0eaba87069093bd7c
Parents: c909cae
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Tue Jun 16 18:00:36 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Tue Jun 16 18:00:36 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java    | 3 ---
 1 file changed, 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4025ce3c/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
index da00d95..7b78bda 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
@@ -36,9 +36,6 @@ import java.util.*;
  * This implementation stores objects in underlying database using java beans mapping description via reflection.
  * <p>
  * Use {@link CacheJdbcPojoStoreFactory} factory to pass {@link CacheJdbcPojoStore} to {@link CacheConfiguration}.
- *
- * @param <K> The type of keys handled by this loader.
- * @param <V> The type of values generated by this loader.
  */
 public class CacheJdbcPojoStore<K, V> extends CacheAbstractJdbcStore<K, V> {
     /**


[12/13] incubator-ignite git commit: Merge remote-tracking branch 'origin/ignite-960' into ignite-960

Posted by yz...@apache.org.
Merge remote-tracking branch 'origin/ignite-960' into ignite-960


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/c909caee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/c909caee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/c909caee

Branch: refs/heads/ignite-960
Commit: c909caee1e43610bcbf3e1350b78525a0e76ca48
Parents: ca89d81 dd8048b
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Tue Jun 16 17:52:15 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Tue Jun 16 17:52:15 2015 +0300

----------------------------------------------------------------------
 modules/spring/src/test/config/node1.xml        |  2 +-
 modules/spring/src/test/config/store-cache1.xml |  2 +-
 .../jdbc/CacheJdbcBlobStoreFactorySelfTest.java | 63 +++++++++++++++++++-
 .../jdbc/CacheJdbcPojoStoreFactorySelfTest.java |  3 +-
 4 files changed, 63 insertions(+), 7 deletions(-)
----------------------------------------------------------------------



[05/13] incubator-ignite git commit: # ignite-sprint-6 tests fixes

Posted by yz...@apache.org.
# ignite-sprint-6 tests fixes


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/a9228c07
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/a9228c07
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/a9228c07

Branch: refs/heads/ignite-960
Commit: a9228c07aa125613df45af226fe133b93c8c2783
Parents: 5b9013f
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jun 16 15:02:21 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jun 16 15:02:21 2015 +0300

----------------------------------------------------------------------
 .../cache/GridCacheMultinodeUpdateAbstractSelfTest.java     | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a9228c07/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java
index ddf42e3..4152229 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java
@@ -33,6 +33,7 @@ import static org.apache.ignite.cache.CacheMode.*;
 /**
  * Multinode update test.
  */
+@SuppressWarnings("unchecked")
 public abstract class GridCacheMultinodeUpdateAbstractSelfTest extends GridCacheAbstractSelfTest {
     /** */
     protected static volatile boolean failed;
@@ -52,6 +53,7 @@ public abstract class GridCacheMultinodeUpdateAbstractSelfTest extends GridCache
         return 3 * 60_000;
     }
 
+    /** {@inheritDoc} */
     @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception {
         CacheConfiguration ccfg = super.cacheConfiguration(gridName);
 
@@ -62,6 +64,13 @@ public abstract class GridCacheMultinodeUpdateAbstractSelfTest extends GridCache
         return ccfg;
     }
 
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        failed = false;
+    }
+
     /**
      * @throws Exception If failed.
      */


[07/13] incubator-ignite git commit: # ignite-sprint-6 enabled test

Posted by yz...@apache.org.
# ignite-sprint-6 enabled test


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/f6b1b79f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/f6b1b79f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/f6b1b79f

Branch: refs/heads/ignite-960
Commit: f6b1b79fa3f354bde733d729c8c99016e09956f8
Parents: a9228c0
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jun 16 16:20:28 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jun 16 16:23:59 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheVersionMultinodeTest.java      | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f6b1b79f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVersionMultinodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVersionMultinodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVersionMultinodeTest.java
index cecb4a9..91dcbf1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVersionMultinodeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheVersionMultinodeTest.java
@@ -81,7 +81,7 @@ public class GridCacheVersionMultinodeTest extends GridCacheAbstractSelfTest {
 
     /** {@inheritDoc} */
     @Override protected void beforeTest() throws Exception {
-        fail("https://issues.apache.org/jira/browse/IGNITE-114");
+        // No-op.
     }
 
     /** {@inheritDoc} */
@@ -240,12 +240,14 @@ public class GridCacheVersionMultinodeTest extends GridCacheAbstractSelfTest {
 
             if (e != null) {
                 if (ver != null) {
-                    assertEquals("Non-equal versions for key: " + key, ver, e.version());
+                    assertEquals("Non-equal versions for key: " + key,
+                        ver,
+                        e instanceof GridNearCacheEntry ? ((GridNearCacheEntry)e).dhtVersion() : e.version());
 
                     verified = true;
                 }
                 else
-                    ver = e.version();
+                    ver = e instanceof GridNearCacheEntry ? ((GridNearCacheEntry)e).dhtVersion() : e.version();
             }
         }