Repository: incubator-ignite
Updated Branches:
  refs/heads/master 7f6fdca44 -> 7b13de917


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/922a2bab/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/GridIndexingSpiAbstractSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/GridIndexingSpiAbstractSelfTest.java
 
b/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/GridIndexingSpiAbstractSelfTest.java
deleted file mode 100644
index bd647f5..0000000
--- 
a/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/GridIndexingSpiAbstractSelfTest.java
+++ /dev/null
@@ -1,594 +0,0 @@
-/* @java.file.header */
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.gridgain.grid.spi.indexing;
-
-import org.apache.ignite.*;
-import org.apache.ignite.marshaller.*;
-import org.apache.ignite.spi.*;
-import org.apache.ignite.spi.indexing.*;
-import org.gridgain.grid.*;
-import org.gridgain.grid.spi.indexing.h2.*;
-import org.gridgain.grid.util.typedef.*;
-import org.gridgain.grid.util.typedef.internal.*;
-import org.gridgain.testframework.*;
-import org.gridgain.testframework.junits.spi.*;
-
-import java.io.*;
-import java.util.*;
-import java.util.concurrent.*;
-
-/**
- * Tests for all SQL based indexing SPI implementations.
- */
-public abstract class GridIndexingSpiAbstractSelfTest<X extends IndexingSpi>
-    extends GridSpiAbstractTest<X> {
-    /** */
-    private static final TextIndex textIdx = new TextIndex(F.asList("txt"));
-
-    /** */
-    private static final Map<String, Class<?>> fieldsAA = new HashMap<>();
-
-    /** */
-    private static final Map<String, Class<?>> fieldsAB = new HashMap<>();
-
-    /** */
-    private static final Map<String, Class<?>> fieldsBA = new HashMap<>();
-
-    /**
-     * Fields initialization.
-     */
-    static {
-        fieldsAA.put("id", Long.class);
-        fieldsAA.put("name", String.class);
-        fieldsAA.put("age", Integer.class);
-
-        fieldsAB.putAll(fieldsAA);
-        fieldsAB.put("txt", String.class);
-
-        fieldsBA.putAll(fieldsAA);
-        fieldsBA.put("sex", Boolean.class);
-    }
-
-    /** */
-    private static TypeDesc typeAA = new TypeDesc("A", "A", fieldsAA, null);
-
-    /** */
-    private static TypeDesc typeAB = new TypeDesc("A", "B", fieldsAB, textIdx);
-
-    /** */
-    private static TypeDesc typeBA = new TypeDesc("B", "A", fieldsBA, null);
-
-    /** {@inheritDoc} */
-    @Override protected void spiConfigure(X spi) throws Exception {
-        super.spiConfigure(spi);
-
-        spi.registerMarshaller(new 
IdxMarshaller(getTestResources().getMarshaller()));
-
-        spi.registerSpace("A");
-        spi.registerSpace("B");
-    }
-
-    /**
-     * @param id Id.
-     * @param name Name.
-     * @param age Age.
-     * @return AA.
-     */
-    private Map<String, Object> aa(long id, String name, int age) {
-        Map<String, Object> map = new HashMap<>();
-
-        map.put("id", id);
-        map.put("name", name);
-        map.put("age", age);
-
-        return map;
-    }
-
-    /**
-     * @param id Id.
-     * @param name Name.
-     * @param age Age.
-     * @param txt Text.
-     * @return AB.
-     */
-    private Map<String, Object> ab(long id, String name, int age, String txt) {
-        Map<String, Object> map = aa(id, name, age);
-
-        map.put("txt", txt);
-
-        return map;
-    }
-
-    /**
-     * @param id Id.
-     * @param name Name.
-     * @param age Age.
-     * @param sex Sex.
-     * @return BA.
-     */
-    private Map<String, Object> ba(long id, String name, int age, boolean sex) 
{
-        Map<String, Object> map = aa(id, name, age);
-
-        map.put("sex", sex);
-
-        return map;
-    }
-
-    /**
-     * @param val Value.
-     * @param <T> Value type.
-     * @return Indexing entity.
-     * @throws GridException If failed.
-     */
-    private <T> IndexingEntity<T> entity(T val) throws GridException {
-        return new IndexingEntityAdapter<>(val, 
getTestResources().getMarshaller().marshal(val));
-    }
-
-    /**
-     * @param row Row
-     * @return Value.
-     * @throws org.apache.ignite.spi.IgniteSpiException If failed.
-     */
-    private Map<String, Object> value(IndexingKeyValueRow<Integer, Map<String, 
Object>> row) throws IgniteSpiException {
-        return row.value().value();
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testSpi() throws Exception {
-        X spi = getSpi();
-
-        assertEquals(-1, spi.size(typeAA.space(), typeAA));
-        assertEquals(-1, spi.size(typeAB.space(), typeAB));
-        assertEquals(-1, spi.size(typeBA.space(), typeBA));
-
-        spi.registerType(typeAA.space(), typeAA);
-
-        assertEquals(0, spi.size(typeAA.space(), typeAA));
-        assertEquals(-1, spi.size(typeAB.space(), typeAB));
-        assertEquals(-1, spi.size(typeBA.space(), typeBA));
-
-        spi.registerType(typeAB.space(), typeAB);
-
-        assertEquals(0, spi.size(typeAA.space(), typeAA));
-        assertEquals(0, spi.size(typeAB.space(), typeAB));
-        assertEquals(-1, spi.size(typeBA.space(), typeBA));
-
-        spi.registerType(typeBA.space(), typeBA);
-
-        // Initially all is empty.
-        assertEquals(0, spi.size(typeAA.space(), typeAA));
-        assertEquals(0, spi.size(typeAB.space(), typeAB));
-        assertEquals(0, spi.size(typeBA.space(), typeBA));
-
-        assertFalse(spi.query(typeAA.space(), "select * from A.A", 
Collections.emptySet(), typeAA, null).hasNext());
-        assertFalse(spi.query(typeAB.space(), "select * from A.B", 
Collections.emptySet(), typeAB, null).hasNext());
-        assertFalse(spi.query(typeBA.space(), "select * from B.A", 
Collections.emptySet(), typeBA, null).hasNext());
-
-        // Nothing to remove.
-        assertFalse(spi.remove("A", new IndexingEntityAdapter<>(1, null)));
-        assertFalse(spi.remove("B", new IndexingEntityAdapter<>(1, null)));
-
-        spi.store(typeAA.space(), typeAA, entity(1), entity(aa(1, "Vasya", 
10)), "v1".getBytes(), 0);
-
-        assertEquals(1, spi.size(typeAA.space(), typeAA));
-        assertEquals(0, spi.size(typeAB.space(), typeAB));
-        assertEquals(0, spi.size(typeBA.space(), typeBA));
-
-        spi.store(typeAB.space(), typeAB, entity(1), entity(ab(1, "Vasya", 20, 
"Some text about Vasya goes here.")),
-            "v2".getBytes(), 0);
-
-        // In one space all keys must be unique.
-        assertEquals(0, spi.size(typeAA.space(), typeAA));
-        assertEquals(1, spi.size(typeAB.space(), typeAB));
-        assertEquals(0, spi.size(typeBA.space(), typeBA));
-
-        spi.store(typeBA.space(), typeBA, entity(1), entity(ba(2, "Petya", 25, 
true)), "v3".getBytes(), 0);
-
-        // No replacement because of different space.
-        assertEquals(0, spi.size(typeAA.space(), typeAA));
-        assertEquals(1, spi.size(typeAB.space(), typeAB));
-        assertEquals(1, spi.size(typeBA.space(), typeBA));
-
-        spi.store(typeBA.space(), typeBA, entity(1), entity(ba(2, "Kolya", 25, 
true)), "v4".getBytes(), 0);
-
-        // Replacement in the same table.
-        assertEquals(0, spi.size(typeAA.space(), typeAA));
-        assertEquals(1, spi.size(typeAB.space(), typeAB));
-        assertEquals(1, spi.size(typeBA.space(), typeBA));
-
-        spi.store(typeAA.space(), typeAA, entity(2), entity(aa(2, "Valera", 
19)), "v5".getBytes(), 0);
-
-        assertEquals(1, spi.size(typeAA.space(), typeAA));
-        assertEquals(1, spi.size(typeAB.space(), typeAB));
-        assertEquals(1, spi.size(typeBA.space(), typeBA));
-
-        spi.store(typeAA.space(), typeAA, entity(3), entity(aa(3, "Borya", 
18)), "v6".getBytes(), 0);
-
-        assertEquals(2, spi.size(typeAA.space(), typeAA));
-        assertEquals(1, spi.size(typeAB.space(), typeAB));
-        assertEquals(1, spi.size(typeBA.space(), typeBA));
-
-        spi.store(typeAB.space(), typeAB, entity(4), entity(ab(4, "Vitalya", 
20, "Very Good guy")), "v7".getBytes(), 0);
-
-        assertEquals(2, spi.size(typeAA.space(), typeAA));
-        assertEquals(2, spi.size(typeAB.space(), typeAB));
-        assertEquals(1, spi.size(typeBA.space(), typeBA));
-
-        // Query data.
-        Iterator<IndexingKeyValueRow<Integer, Map<String, Object>>> res =
-            spi.query(typeAA.space(), "select * from a order by age", 
Collections.emptySet(), typeAA, null);
-
-        assertTrue(res.hasNext());
-        assertEquals(aa(3, "Borya", 18), value(res.next()));
-        assertTrue(res.hasNext());
-        assertEquals(aa(2, "Valera", 19), value(res.next()));
-        assertFalse(res.hasNext());
-
-        res = spi.query(typeAB.space(), "select * from b order by name", 
Collections.emptySet(), typeAB, null);
-
-        assertTrue(res.hasNext());
-        assertEquals(ab(1, "Vasya", 20, "Some text about Vasya goes here."), 
value(res.next()));
-        assertTrue(res.hasNext());
-        assertEquals(ab(4, "Vitalya", 20, "Very Good guy"), value(res.next()));
-        assertFalse(res.hasNext());
-
-        res = spi.query(typeBA.space(), "select * from a", 
Collections.emptySet(), typeBA, null);
-
-        assertTrue(res.hasNext());
-        assertEquals(ba(2, "Kolya", 25, true), value(res.next()));
-        assertFalse(res.hasNext());
-
-        // Text queries
-        Iterator<IndexingKeyValueRow<Integer, Map<String, Object>>> txtRes = 
spi.queryText(typeAB.space(), "good",
-            typeAB, null);
-
-        assertTrue(txtRes.hasNext());
-        assertEquals(ab(4, "Vitalya", 20, "Very Good guy"), 
value(txtRes.next()));
-        assertFalse(txtRes.hasNext());
-
-        // Fields query
-        IndexingFieldsResult fieldsRes =
-            spi.queryFields(null, "select a.a.name n1, a.a.age a1, b.a.name 
n2, " +
-            "b.a.age a2 from a.a, b.a where a.a.id = b.a.id ", 
Collections.emptySet(), null);
-
-        String[] aliases = {"N1", "A1", "N2", "A2"};
-        Object[] vals = { "Valera", 19, "Kolya", 25};
-
-        assertTrue(fieldsRes.iterator().hasNext());
-
-        List<IndexingEntity<?>> fields = fieldsRes.iterator().next();
-
-        assertEquals(4, fields.size());
-
-        int i = 0;
-
-        for (IndexingEntity<?> f : fields) {
-            assertEquals(aliases[i], fieldsRes.metaData().get(i).fieldName());
-            assertEquals(vals[i++], f.value());
-        }
-
-        assertFalse(fieldsRes.iterator().hasNext());
-
-        // Query on not existing table should not fail.
-        assertFalse(spi.queryFields(null, "select * from not_existing_table",
-            Collections.emptySet(), null).iterator().hasNext());
-
-        // Remove
-        spi.remove(typeAA.space(), entity(2));
-
-        assertEquals(1, spi.size(typeAA.space(), typeAA));
-        assertEquals(2, spi.size(typeAB.space(), typeAB));
-        assertEquals(1, spi.size(typeBA.space(), typeBA));
-
-        spi.remove(typeBA.space(), entity(1));
-
-        assertEquals(1, spi.size(typeAA.space(), typeAA));
-        assertEquals(2, spi.size(typeAB.space(), typeAB));
-        assertEquals(0, spi.size(typeBA.space(), typeBA));
-
-        boolean h2IdxOffheap = (spi instanceof GridH2IndexingSpi) &&
-                ((GridH2IndexingSpiMBean)spi).getMaxOffHeapMemory() > 0;
-
-        // At the time of this writing index rebuilding is not supported for 
GridH2IndexingSpi with off-heap storage.
-        if (!h2IdxOffheap) {
-            // Rebuild
-
-            spi.rebuildIndexes(typeAB.space(), typeAB);
-
-            assertEquals(1, spi.size(typeAA.space(), typeAA));
-            assertEquals(2, spi.size(typeAB.space(), typeAB));
-            assertEquals(0, spi.size(typeBA.space(), typeBA));
-
-            // For invalid space name/type should not fail.
-            spi.rebuildIndexes("not_existing_space", typeAA);
-            spi.rebuildIndexes(typeAA.space(), new TypeDesc("C", "C", 
fieldsAA, null));
-        }
-
-        // Unregister.
-        spi.unregisterType(typeAA.space(), typeAA);
-
-        assertEquals(-1, spi.size(typeAA.space(), typeAA));
-        assertEquals(2, spi.size(typeAB.space(), typeAB));
-        assertEquals(0, spi.size(typeBA.space(), typeBA));
-
-        spi.unregisterType(typeAB.space(), typeAB);
-
-        assertEquals(-1, spi.size(typeAA.space(), typeAA));
-        assertEquals(-1, spi.size(typeAB.space(), typeAB));
-        assertEquals(0, spi.size(typeBA.space(), typeBA));
-
-        spi.unregisterType(typeBA.space(), typeBA);
-
-        // Should not store but should not fail as well.
-        spi.store(typeAA.space(), typeAA, entity(10), entity(aa(1, "Fail", 
100500)), "v220".getBytes(), 0);
-
-        assertEquals(-1, spi.size(typeAA.space(), typeAA));
-    }
-
-    /**
-     * Test long queries write explain warnings into log.
-     *
-     * @throws Exception If failed.
-     */
-    public void testLongQueries() throws Exception {
-        X spi = getSpi();
-
-        if (!(spi instanceof GridH2IndexingSpi))
-            return;
-
-        long longQryExecTime = 100;
-
-        GridStringLogger log = new GridStringLogger(false, this.log);
-
-        IgniteLogger oldLog = GridTestUtils.getFieldValue(spi, "log");
-        ((GridH2IndexingSpi)spi).setLongQueryExecutionTimeout(longQryExecTime);
-        ((GridH2IndexingSpi) spi).setLongQueryExplain(true);
-
-        try {
-            GridTestUtils.setFieldValue(spi, "log", log);
-
-            String sql = "select sum(x) FROM SYSTEM_RANGE(?, ?)";
-
-            long now = U.currentTimeMillis();
-            long time = now;
-
-            long range = 1000000L;
-
-            while (now - time <= longQryExecTime * 3 / 2) {
-                time = now;
-                range *= 3;
-
-                IndexingFieldsResult res = spi.queryFields(null, sql, 
Arrays.<Object>asList(1, range), null);
-
-                assert res.iterator().hasNext();
-
-                now = U.currentTimeMillis();
-            }
-
-            String res = log.toString();
-
-            F.println(res);
-
-            assert res.contains("/* PUBLIC.RANGE_INDEX */");
-        }
-        finally {
-            GridTestUtils.setFieldValue(spi, "log", oldLog);
-            ((GridH2IndexingSpi)spi).setLongQueryExecutionTimeout(3000);
-        }
-    }
-
-    public void _testResultReuse() throws Exception {
-        final X spi = getSpi();
-
-        multithreaded(new Callable<Object>() {
-              @Override public Object call() throws Exception {
-                  return spi.queryFields(null, "SELECT sum(x) + sum(x) + 
sum(x) + sum(x) FROM SYSTEM_RANGE(?, ?)",
-                      F.<Object>asList(0, 7000000), null);
-              }
-          }, 5);
-    }
-
-    /**
-     * Test long queries write explain warnings into log.
-     *
-     * @throws Exception If failed.
-     */
-    public void testZeroLongQuery() throws Exception {
-        X spi = getSpi();
-
-        if (!(spi instanceof GridH2IndexingSpi))
-            return;
-
-        long longQryExecTime = -1;
-
-        GridStringLogger log = new GridStringLogger(false, this.log);
-
-        IgniteLogger oldLog = GridTestUtils.getFieldValue(spi, "log");
-        ((GridH2IndexingSpi)spi).setLongQueryExecutionTimeout(longQryExecTime);
-        ((GridH2IndexingSpi) spi).setLongQueryExplain(true);
-
-        try {
-            GridTestUtils.setFieldValue(spi, "log", log);
-
-            String sql = "SELECT * FROM MyNonExistingTable";
-
-            IndexingFieldsResult res = spi.queryFields(null, sql, 
Collections.emptyList(), null);
-
-            assertFalse(res.iterator().hasNext());
-
-            String logStr = log.toString();
-
-            F.println(logStr);
-
-            assertTrue(logStr.contains("Failed to explain plan because 
required table does not exist"));
-        }
-        finally {
-            GridTestUtils.setFieldValue(spi, "log", oldLog);
-            ((GridH2IndexingSpi)spi).setLongQueryExecutionTimeout(3000);
-        }
-    }
-
-    /**
-     * Index descriptor.
-     */
-    private static class TextIndex implements IndexDescriptor {
-        /** */
-        private final Collection<String> fields;
-
-        /**
-         * @param fields Fields.
-         */
-        private TextIndex(Collection<String> fields) {
-            this.fields = Collections.unmodifiableCollection(fields);
-        }
-
-        /** {@inheritDoc} */
-        @Override public Collection<String> fields() {
-            return fields;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean descending(String field) {
-            return false;
-        }
-
-        /** {@inheritDoc} */
-        @Override public IndexType type() {
-            return IndexType.FULLTEXT;
-        }
-    }
-
-    /**
-     * Type descriptor.
-     */
-    private static class TypeDesc implements IndexingTypeDescriptor {
-        /** */
-        private final String name;
-
-        /** */
-        private final String space;
-
-        /** */
-        private final Map<String, Class<?>> valFields;
-
-        /** */
-        private final IndexDescriptor textIdx;
-
-        /**
-         * @param space Space name.
-         * @param name Type name.
-         * @param valFields Fields.
-         * @param textIdx Fulltext index.
-         */
-        private TypeDesc(String space, String name, Map<String, Class<?>> 
valFields, IndexDescriptor textIdx) {
-            this.name = name;
-            this.space = space;
-            this.valFields = Collections.unmodifiableMap(valFields);
-            this.textIdx = textIdx;
-        }
-
-        /** {@inheritDoc} */
-        @Override public String name() {
-            return name;
-        }
-
-        /**
-         * @return Space name.
-         */
-        public String space() {
-            return space;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Map<String, Class<?>> valueFields() {
-            return valFields;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Map<String, Class<?>> keyFields() {
-            return Collections.emptyMap();
-        }
-
-        /** {@inheritDoc} */
-        @Override public <T> T value(Object obj, String field) throws 
IgniteSpiException {
-            assert obj != null;
-            assert !F.isEmpty(field);
-
-            return (T)((Map<String, Object>) obj).get(field);
-        }
-
-        /** */
-        @Override public Map<String, IndexDescriptor> indexes() {
-            return textIdx == null ? Collections.<String, 
IndexDescriptor>emptyMap() :
-                Collections.singletonMap("index", textIdx);
-        }
-
-        /** */
-        @Override public Class<?> valueClass() {
-            return Object.class;
-        }
-
-        /** */
-        @Override public Class<?> keyClass() {
-            return Integer.class;
-        }
-
-        /** */
-        @Override public boolean valueTextIndex() {
-            return textIdx == null;
-        }
-    }
-
-    /**
-     * Indexing marshaller.
-     */
-    private static class IdxMarshaller implements IndexingMarshaller {
-        /** */
-        private final IgniteMarshaller marshaller;
-
-        /**
-         * @param marshaller Marshaller.
-         */
-        private IdxMarshaller(IgniteMarshaller marshaller) {
-            this.marshaller = marshaller;
-        }
-
-        /** {@inheritDoc} */
-        @Override public <T> IndexingEntity<T> unmarshal(byte[] bytes) throws 
IgniteSpiException {
-            try {
-                return new IndexingEntityAdapter<>(
-                    (T)marshaller.unmarshal(bytes, 
getClass().getClassLoader()), bytes);
-            }
-            catch (GridException e) {
-                throw new IgniteSpiException(e);
-            }
-        }
-
-        /** {@inheritDoc} */
-        @Override public byte[] marshal(IndexingEntity<?> entity) throws 
IgniteSpiException {
-            if (entity.bytes() != null)
-                return entity.bytes();
-
-            ByteArrayOutputStream out = new ByteArrayOutputStream();
-
-            try {
-                marshaller.marshal(entity.value(), out);
-            }
-            catch (GridException e) {
-                throw new IgniteSpiException(e);
-            }
-
-            return out.toByteArray();
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/922a2bab/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexRebuildTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexRebuildTest.java
 
b/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexRebuildTest.java
deleted file mode 100644
index e9ec568..0000000
--- 
a/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexRebuildTest.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/* @java.file.header */
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.gridgain.grid.spi.indexing.h2;
-
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.spi.indexing.*;
-import org.gridgain.grid.*;
-import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.query.*;
-import org.gridgain.grid.kernal.processors.cache.*;
-import org.gridgain.grid.util.typedef.internal.*;
-import org.gridgain.testframework.*;
-import org.jetbrains.annotations.*;
-
-import java.util.*;
-import java.util.concurrent.*;
-
-/**
- */
-public class GridH2IndexRebuildTest extends GridCacheAbstractSelfTest {
-    /** */
-    private static final int GRID_CNT = 1;
-
-    /** {@inheritDoc} */
-    @Override protected int gridCount() {
-        return GRID_CNT;
-    }
-
-    /**
-     * Overrides rebuildIndexes to check it can be interrupted.
-     */
-    private static class SleepingH2Indexing extends GridH2IndexingSpi {
-        /** */
-        private volatile boolean sleepInRebuild;
-
-        /** */
-        private volatile boolean interrupted;
-
-        /** {@inheritDoc} */
-        @Override public void rebuildIndexes(@Nullable String spaceName, 
IndexingTypeDescriptor type) {
-            if (sleepInRebuild) {
-                try {
-                    U.sleep(Long.MAX_VALUE);
-                }
-                catch (GridInterruptedException ignored) {
-                    interrupted = true;
-                }
-            }
-
-            super.rebuildIndexes(spaceName, type);
-        }
-    }
-
-    /** */
-    private static SleepingH2Indexing spi;
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        spi = new SleepingH2Indexing();
-
-        cfg.setIndexingSpi(spi);
-
-        return cfg;
-    }
-
-    /**
-     * Value class with regular and compound indexes.
-     */
-    @SuppressWarnings("UnusedDeclaration")
-    private static class TestValue1 {
-        /** */
-        @GridCacheQuerySqlField(index = true)
-        private long val1;
-
-        /** */
-        @GridCacheQuerySqlField(index = true)
-        private String val2;
-
-        /** */
-        @GridCacheQuerySqlField(groups = "group1")
-        private int val3;
-
-        /** */
-        @GridCacheQuerySqlField(groups = "group1")
-        private int val4;
-
-        /**
-         */
-        TestValue1(long val1, String val2, int val3, int val4) {
-            this.val1 = val1;
-            this.val2 = val2;
-            this.val3 = val3;
-            this.val4 = val4;
-        }
-    }
-
-    /**
-     * Value class with regular and text indexes.
-     */
-    @SuppressWarnings("UnusedDeclaration")
-    private static class TestValue2 {
-        /** */
-        @GridCacheQuerySqlField(index = true)
-        private long val1;
-
-        /** */
-        @GridCacheQueryTextField
-        private String val2;
-
-        /**
-         */
-        TestValue2(long val1, String val2) {
-            this.val1 = val1;
-            this.val2 = val2;
-        }
-    }
-
-    /** */
-    private static final int ENTRY_CNT = 10000;
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testRebuildIndexes() throws Exception {
-        cache().queries().rebuildIndexes(ArrayList.class).get();
-
-        cache().queries().rebuildAllIndexes().get();
-
-        GridCache<Integer, TestValue1> cache1 = grid(0).cache(null);
-        GridCache<Integer, TestValue2> cache2 = grid(0).cache(null);
-
-        for (int i = 0; i < ENTRY_CNT; i++) {
-            cache1.put(i, new TestValue1(i, "val2-" + i, i, i));
-            cache2.put(ENTRY_CNT * 2 + i, new TestValue2(i, "val2-" + i));
-        }
-
-        GridCacheQuery<Map.Entry<Integer, TestValue1>> qry1 =
-            cache1.queries().createSqlQuery(TestValue1.class, "val1 = 9000");
-
-        GridCacheQuery<Map.Entry<Integer, TestValue1>> qry2 =
-            cache1.queries().createSqlQuery(TestValue1.class, "val2 = 
'val2-9000'");
-
-        GridCacheQuery<Map.Entry<Integer, TestValue1>> qry3 =
-            cache1.queries().createSqlQuery(TestValue1.class, "val3 = 9000 and 
val4 = 9000");
-
-        GridCacheQuery<Map.Entry<Integer, TestValue2>> qry4 =
-            cache2.queries().createSqlQuery(TestValue2.class, "val1 = 9000");
-
-        GridCacheQuery<Map.Entry<Integer, TestValue2>> qry5 =
-            cache2.queries().createFullTextQuery(TestValue2.class, "val2 = 
'val2-9000'");
-
-        checkQueryReturnsOneEntry(qry1, qry2, qry3, qry4, qry5);
-
-        for (int i = 0; i < ENTRY_CNT / 2; i++) {
-            cache1.remove(i);
-            cache2.remove(ENTRY_CNT * 2 + i);
-        }
-
-        cache().queries().rebuildIndexes(TestValue1.class).get();
-        cache().queries().rebuildIndexes(TestValue2.class).get();
-
-        checkQueryReturnsOneEntry(qry1, qry2, qry3, qry4, qry5);
-
-        cache().queries().rebuildAllIndexes().get();
-
-        checkQueryReturnsOneEntry(qry1, qry2, qry3, qry4, qry5);
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testRebuildInterrupted() throws Exception {
-        spi.sleepInRebuild = true;
-
-        GridCache<Integer, TestValue1> cache1 = grid(0).cache(null);
-        GridCache<Integer, TestValue2> cache2 = grid(0).cache(null);
-
-        cache1.put(0, new TestValue1(0, "val0", 0 ,0));
-        cache2.put(1, new TestValue2(0, "val0"));
-
-        
checkCancel(grid(0).cache(null).queries().rebuildIndexes("TestValue1"));
-
-        checkCancel(grid(0).cache(null).queries().rebuildAllIndexes());
-
-        spi.sleepInRebuild = false;
-
-        final IgniteFuture<?> fut1 = 
grid(0).cache(null).queries().rebuildIndexes(TestValue1.class);
-
-        assertFalse(fut1.isCancelled());
-
-        fut1.get();
-
-        final IgniteFuture<?> fut2 = 
grid(0).cache(null).queries().rebuildAllIndexes();
-
-        assertFalse(fut2.isCancelled());
-
-        fut2.get();
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    private void checkCancel(final IgniteFuture<?> fut) throws Exception {
-        assertTrue(fut.cancel());
-
-        GridTestUtils.assertThrows(log, new Callable<Void>() {
-            @Override
-            public Void call() throws Exception {
-                fut.get();
-                return null;
-            }
-        }, IgniteFutureCancelledException.class, null);
-
-        assertTrue(spi.interrupted);
-
-        spi.interrupted = false;
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    private void checkQueryReturnsOneEntry(GridCacheQuery<?>... qrys) throws 
Exception {
-        for (GridCacheQuery<?> qry : qrys)
-            assertEquals(1, qry.execute().get().size());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/922a2bab/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiGeoSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiGeoSelfTest.java
 
b/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiGeoSelfTest.java
deleted file mode 100644
index 969e414..0000000
--- 
a/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiGeoSelfTest.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/* @java.file.header */
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.gridgain.grid.spi.indexing.h2;
-
-import com.vividsolutions.jts.geom.*;
-import com.vividsolutions.jts.io.*;
-import org.apache.ignite.lang.*;
-import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.query.*;
-import org.gridgain.grid.kernal.processors.cache.*;
-import org.gridgain.grid.util.typedef.*;
-import org.gridgain.grid.util.typedef.internal.*;
-import org.gridgain.testframework.*;
-
-import java.io.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-
-/**
- *
- */
-public class GridH2IndexingSpiGeoSelfTest extends GridCacheAbstractSelfTest {
-    /** */
-    private static final int CNT = 100;
-
-    /** */
-    private static final long DUR = 60000L;
-
-    /** {@inheritDoc} */
-    @Override protected int gridCount() {
-        return 3;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected long getTestTimeout() {
-        return DUR * 3;
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    @SuppressWarnings("unchecked")
-    public void testGeo() throws Exception {
-        GridCache<Integer, EnemyCamp> cache = grid(0).cache(null);
-
-        WKTReader r = new WKTReader();
-
-        cache.put(0, new EnemyCamp(r.read("POINT(25 75)"), "A"));
-        cache.put(1, new EnemyCamp(r.read("POINT(70 70)"), "B"));
-        cache.put(2, new EnemyCamp(r.read("POINT(70 30)"), "C"));
-        cache.put(3, new EnemyCamp(r.read("POINT(75 25)"), "D"));
-
-        GridCacheQuery<Map.Entry<Integer, EnemyCamp>> qry = 
cache.queries().createSqlQuery(EnemyCamp.class,
-            "coords && ?");
-
-        Collection<Map.Entry<Integer, EnemyCamp>> res = 
qry.execute(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 70))"))
-            .get();
-
-        checkPoints(res, "A");
-
-        res = qry.execute(r.read("POLYGON((10 5, 10 35, 70 30, 75 25, 10 
5))")).get();
-
-        checkPoints(res, "C", "D");
-
-        // Move B to the first polygon.
-        cache.put(1, new EnemyCamp(r.read("POINT(20 75)"), "B"));
-
-        res = qry.execute(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 
70))")).get();
-
-        checkPoints(res, "A", "B");
-
-        // Move B to the second polygon.
-        cache.put(1, new EnemyCamp(r.read("POINT(30 30)"), "B"));
-
-        res = qry.execute(r.read("POLYGON((10 5, 10 35, 70 30, 75 25, 10 
5))")).get();
-
-        checkPoints(res, "B", "C", "D");
-
-        // Remove B.
-        cache.remove(1);
-
-        res = qry.execute(r.read("POLYGON((5 70, 5 80, 30 80, 30 70, 5 
70))")).get();
-
-        checkPoints(res, "A");
-
-        res = qry.execute(r.read("POLYGON((10 5, 10 35, 70 30, 75 25, 10 
5))")).get();
-
-        checkPoints(res, "C", "D");
-
-        // Check explaint request.
-        assertTrue(F.first(cache.queries().createSqlFieldsQuery("explain 
select * from EnemyCamp " +
-            "where coords && 'POINT(25 
75)'").execute().get()).get(0).toString().contains("coords_idx"));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    @SuppressWarnings("unchecked")
-    public void testGeoMultithreaded() throws Exception {
-        final GridCache<Integer, EnemyCamp> cache1 = grid(0).cache(null);
-        final GridCache<Integer, EnemyCamp> cache2 = grid(1).cache(null);
-        final GridCache<Integer, EnemyCamp> cache3 = grid(2).cache(null);
-
-        final String[] points = new String[CNT];
-
-        WKTReader r = new WKTReader();
-
-        ThreadLocalRandom rnd = ThreadLocalRandom.current();
-
-        for (int idx = 0; idx < CNT; idx++) {
-            int x = rnd.nextInt(1, 100);
-            int y = rnd.nextInt(1, 100);
-
-            cache1.put(idx, new EnemyCamp(r.read("POINT(" + x + " " + y + 
")"), Integer.toString(idx)));
-
-            points[idx] = Integer.toString(idx);
-        }
-
-        Thread.sleep(200);
-
-        final AtomicBoolean stop = new AtomicBoolean();
-        final AtomicReference<Exception> err = new AtomicReference<>();
-
-        IgniteFuture<?> putFut = GridTestUtils.runMultiThreadedAsync(new 
Callable<Void>() {
-            @Override public Void call() throws Exception {
-                WKTReader r = new WKTReader();
-
-                ThreadLocalRandom rnd = ThreadLocalRandom.current();
-
-                while (!stop.get()) {
-                    int cacheIdx = rnd.nextInt(0, 3);
-
-                    GridCache<Integer, EnemyCamp> cache = cacheIdx == 0 ? 
cache1 : cacheIdx == 1 ? cache2 : cache3;
-
-                    int idx = rnd.nextInt(CNT);
-                    int x = rnd.nextInt(1, 100);
-                    int y = rnd.nextInt(1, 100);
-
-                    cache.put(idx, new EnemyCamp(r.read("POINT(" + x + " " + y 
+ ")"), Integer.toString(idx)));
-
-                    U.sleep(50);
-                }
-
-                return null;
-            }
-        }, Runtime.getRuntime().availableProcessors(), "put-thread");
-
-        IgniteFuture<?> qryFut = GridTestUtils.runMultiThreadedAsync(new 
Callable<Void>() {
-            @Override public Void call() throws Exception {
-                WKTReader r = new WKTReader();
-
-                ThreadLocalRandom rnd = ThreadLocalRandom.current();
-
-                while (!stop.get()) {
-                    try {
-                        int cacheIdx = rnd.nextInt(0, 3);
-
-                        GridCache<Integer, EnemyCamp> cache = cacheIdx == 0 ? 
cache1 : cacheIdx == 1 ? cache2 : cache3;
-
-                        GridCacheQuery<Map.Entry<Integer, EnemyCamp>> qry = 
cache.queries().createSqlQuery(
-                            EnemyCamp.class, "coords && ?");
-
-                        Collection<Map.Entry<Integer, EnemyCamp>> res = 
qry.execute(
-                            r.read("POLYGON((0 0, 0 100, 100 100, 100 0, 0 
0))")).get();
-
-                        checkPoints(res, points);
-
-                        U.sleep(5);
-                    }
-                    catch (Exception e) {
-                        err.set(e);
-
-                        stop.set(true);
-
-                        break;
-                    }
-                }
-
-                return null;
-            }
-        }, 4, "qry-thread");
-
-        U.sleep(60000L);
-
-        stop.set(true);
-
-        putFut.get();
-        qryFut.get();
-
-        Exception err0 = err.get();
-
-        if (err0 != null)
-            throw err0;
-    }
-
-    /**
-     * Check whether result contains all required points.
-     *
-     * @param res Result.
-     * @param points Expected points.
-     */
-    private void checkPoints( Collection<Map.Entry<Integer, EnemyCamp>> res, 
String... points) {
-        Set<String> set = new HashSet<>(Arrays.asList(points));
-
-        assertEquals(set.size(), res.size());
-
-        for (Map.Entry<Integer, EnemyCamp> e : res)
-            assertTrue(set.remove(e.getValue().name));
-    }
-
-    /**
-     *
-     */
-    private static class EnemyCamp implements Serializable {
-        /** */
-        @GridCacheQuerySqlField(index = true)
-        private Geometry coords;
-
-        /** */
-        @GridCacheQuerySqlField
-        private String name;
-
-        /**
-         * @param coords Coordinates.
-         * @param name Name.
-         */
-        private EnemyCamp(Geometry coords, String name) {
-            this.coords = coords;
-            this.name = name;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/922a2bab/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiInMemSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiInMemSelfTest.java
 
b/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiInMemSelfTest.java
deleted file mode 100644
index dacaa52..0000000
--- 
a/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiInMemSelfTest.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/* @java.file.header */
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.gridgain.grid.spi.indexing.h2;
-
-import org.gridgain.grid.spi.indexing.*;
-import org.gridgain.testframework.junits.spi.*;
-
-/**
- * Tests for H2 indexing SPI.
- */
-@GridSpiTest(spi = GridH2IndexingSpi.class, group = "Indexing SPI")
-public class GridH2IndexingSpiInMemSelfTest extends 
GridIndexingSpiAbstractSelfTest<GridH2IndexingSpi> {
-    // No-op.
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/922a2bab/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiInMemStartStopSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiInMemStartStopSelfTest.java
 
b/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiInMemStartStopSelfTest.java
deleted file mode 100644
index 98ec281..0000000
--- 
a/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiInMemStartStopSelfTest.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/* @java.file.header */
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.gridgain.grid.spi.indexing.h2;
-
-import org.gridgain.grid.spi.*;
-import org.gridgain.testframework.junits.spi.*;
-
-/**
- * Start/stop tests for H2 indexing SPI.
- */
-@GridSpiTest(spi = GridH2IndexingSpi.class, group = "Indexing SPI")
-public class GridH2IndexingSpiInMemStartStopSelfTest extends 
GridSpiStartStopAbstractTest<GridH2IndexingSpi>{
-    // No-op.
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/922a2bab/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiOffheapSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiOffheapSelfTest.java
 
b/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiOffheapSelfTest.java
deleted file mode 100644
index f08e4c9..0000000
--- 
a/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiOffheapSelfTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/* @java.file.header */
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.gridgain.grid.spi.indexing.h2;
-
-import org.gridgain.grid.spi.indexing.*;
-import org.gridgain.testframework.junits.spi.*;
-
-/**
- * Tests for H2 indexing SPI.
- */
-@GridSpiTest(spi = GridH2IndexingSpi.class, group = "Indexing SPI")
-public class GridH2IndexingSpiOffheapSelfTest extends 
GridIndexingSpiAbstractSelfTest<GridH2IndexingSpi> {
-    /** */
-    private static final long offheap = 10000000;
-
-    private static GridH2IndexingSpi currentSpi;
-
-    /** {@inheritDoc} */
-    @Override protected void spiConfigure(GridH2IndexingSpi spi) throws 
Exception {
-        super.spiConfigure(spi);
-
-        spi.setMaxOffHeapMemory(offheap);
-
-        currentSpi = spi;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterSpiStopped() throws Exception {
-        super.afterSpiStopped();
-
-        assertEquals(0, currentSpi.getAllocatedOffHeapMemory());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/922a2bab/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiOffheapStartStopSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiOffheapStartStopSelfTest.java
 
b/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiOffheapStartStopSelfTest.java
deleted file mode 100644
index 9a82977..0000000
--- 
a/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpiOffheapStartStopSelfTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/* @java.file.header */
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.gridgain.grid.spi.indexing.h2;
-
-import org.gridgain.grid.spi.*;
-import org.gridgain.testframework.junits.spi.*;
-
-/**
- * Start/stop tests for H2 indexing SPI.
- */
-@GridSpiTest(spi = GridH2IndexingSpi.class, group = "Indexing SPI")
-public class GridH2IndexingSpiOffheapStartStopSelfTest extends 
GridSpiStartStopAbstractTest<GridH2IndexingSpi>{
-    /** */
-    private static final long offheap = 10000000;
-
-    private static GridH2IndexingSpi currentSpi;
-
-    /** {@inheritDoc} */
-    protected void spiConfigure(GridH2IndexingSpi spi) throws Exception {
-        super.spiConfigure(spi);
-
-        spi.setMaxOffHeapMemory(offheap);
-
-        currentSpi = spi;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterSpiStopped() throws Exception {
-        super.afterSpiStopped();
-
-        assertEquals(0, currentSpi.getAllocatedOffHeapMemory());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/922a2bab/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2TableSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2TableSelfTest.java
 
b/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2TableSelfTest.java
deleted file mode 100644
index ee112f1..0000000
--- 
a/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2TableSelfTest.java
+++ /dev/null
@@ -1,613 +0,0 @@
-/* @java.file.header */
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.gridgain.grid.spi.indexing.h2.opt;
-
-import org.gridgain.testframework.junits.common.*;
-import org.h2.Driver;
-import org.h2.index.*;
-import org.h2.result.*;
-import org.h2.table.*;
-import org.h2.value.*;
-import org.jetbrains.annotations.*;
-import org.junit.*;
-
-import java.sql.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-
-/**
- * Tests H2 Table.
- */
-@SuppressWarnings({"TypeMayBeWeakened", 
"FieldAccessedSynchronizedAndUnsynchronized"})
-public class GridH2TableSelfTest extends GridCommonAbstractTest {
-    /** */
-    private static final long MAX_X = 2000;
-
-    /** */
-    private static final String DB_URL = 
"jdbc:h2:mem:gg_table_engine;MULTI_THREADED=1;OPTIMIZE_REUSE_RESULTS=0;" +
-        "QUERY_CACHE_SIZE=0;RECOMPILE_ALWAYS=1";
-
-    /** */
-    private static final String CREATE_TABLE_SQL = "CREATE TABLE T(ID UUID, T 
TIMESTAMP, STR VARCHAR, X BIGINT)";
-
-    /** */
-    private static final String PK_NAME = "__GG_PK_";
-
-    /** */
-    private static final String STR_IDX_NAME = "__GG_IDX_";
-
-    /** */
-    private static final String NON_UNIQUE_IDX_NAME = "__GG_IDX_";
-
-    /** */
-    private static final String SCAN_IDX_NAME = 
GridH2Table.ScanIndex.SCAN_INDEX_NAME_SUFFIX;
-
-    /** */
-    private Connection conn;
-
-    /** */
-    private GridH2Table tbl;
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        Driver.load();
-
-        conn = DriverManager.getConnection(DB_URL);
-
-        tbl = GridH2Table.Engine.createTable(conn, CREATE_TABLE_SQL, null, new 
GridH2Table.IndexesFactory() {
-            @Override public ArrayList<Index> createIndexes(GridH2Table tbl) {
-                ArrayList<Index> idxs = new ArrayList<>();
-
-                IndexColumn id = tbl.indexColumn(0, SortOrder.ASCENDING);
-                IndexColumn t = tbl.indexColumn(1, SortOrder.ASCENDING);
-                IndexColumn str = tbl.indexColumn(2, SortOrder.DESCENDING);
-                IndexColumn x = tbl.indexColumn(3, SortOrder.DESCENDING);
-
-                idxs.add(new GridH2TreeIndex(PK_NAME, tbl, true, 0, 1, id));
-                idxs.add(new GridH2TreeIndex(NON_UNIQUE_IDX_NAME, tbl, false, 
0, 1, x, t));
-                idxs.add(new GridH2TreeIndex(STR_IDX_NAME, tbl, false, 0, 1, 
str));
-
-                return idxs;
-            }
-        }, null);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        conn.close();
-
-        conn = null;
-        tbl = null;
-    }
-
-    /**
-     * @param id Id.
-     * @param t Timestamp.
-     * @param str String.
-     * @param x X.
-     * @return New row.
-     */
-    private GridH2Row row(UUID id, long t, String str, long x) {
-        return new GridH2Row(ValueUuid.get(id.getMostSignificantBits(), 
id.getLeastSignificantBits()),
-            ValueTimestamp.get(new Timestamp(t)),
-            ValueString.get(str),
-            ValueLong.get(x));
-    }
-
-
-    /**
-     * Simple table test.
-     *
-     * @throws Exception If failed.
-     */
-    public void testTable() throws Exception {
-        // Test insert.
-        long x = MAX_X;
-
-        Random rnd = new Random();
-
-        while(x-- > 0) {
-            UUID id = UUID.randomUUID();
-
-            GridH2Row row = row(id, System.currentTimeMillis(), 
rnd.nextBoolean() ? id.toString() :
-                UUID.randomUUID().toString(), rnd.nextInt(100));
-
-            tbl.doUpdate(row, false);
-        }
-
-        assertEquals(MAX_X, tbl.getRowCountApproximation());
-        assertEquals(MAX_X, tbl.getRowCount(null));
-
-        for (GridH2IndexBase idx : tbl.indexes()) {
-            assertEquals(MAX_X, idx.getRowCountApproximation());
-            assertEquals(MAX_X, idx.getRowCount(null));
-        }
-
-        // Check correct rows order.
-        checkOrdered((GridH2TreeIndex)tbl.indexes().get(0), new 
Comparator<SearchRow>() {
-            @Override public int compare(SearchRow o1, SearchRow o2) {
-                UUID id1 = (UUID)o1.getValue(0).getObject();
-                UUID id2 = (UUID)o2.getValue(0).getObject();
-
-                return id1.compareTo(id2);
-            }
-        });
-
-        checkOrdered((GridH2TreeIndex)tbl.indexes().get(1), new 
Comparator<SearchRow>() {
-            @Override public int compare(SearchRow o1, SearchRow o2) {
-                Long x1 = (Long)o1.getValue(3).getObject();
-                Long x2 = (Long)o2.getValue(3).getObject();
-
-                int c = x2.compareTo(x1);
-
-                if (c != 0)
-                    return c;
-
-                Timestamp t1 = (Timestamp)o1.getValue(1).getObject();
-                Timestamp t2 = (Timestamp)o2.getValue(1).getObject();
-
-                return t1.compareTo(t2);
-            }
-        });
-
-        checkOrdered((GridH2TreeIndex)tbl.indexes().get(2), new 
Comparator<SearchRow>() {
-            @Override public int compare(SearchRow o1, SearchRow o2) {
-                String s1 = (String)o1.getValue(2).getObject();
-                String s2 = (String)o2.getValue(2).getObject();
-
-                return s2.compareTo(s1);
-            }
-        });
-
-        // Indexes data consistency.
-        ArrayList<? extends Index> idxs = tbl.indexes();
-
-        checkIndexesConsistent((ArrayList<Index>)idxs, null);
-
-        // Check unique index.
-        UUID id = UUID.randomUUID();
-        UUID id2 = UUID.randomUUID();
-
-        assertTrue(tbl.doUpdate(row(id, System.currentTimeMillis(), 
id.toString(), rnd.nextInt(100)), false));
-        assertTrue(tbl.doUpdate(row(id2, System.currentTimeMillis(), 
id2.toString(), rnd.nextInt(100)), false));
-
-        // Check index selection.
-        checkQueryPlan(conn, "SELECT * FROM T", SCAN_IDX_NAME);
-
-        checkQueryPlan(conn, "SELECT * FROM T WHERE ID IS NULL", PK_NAME);
-        checkQueryPlan(conn, "SELECT * FROM T WHERE ID = RANDOM_UUID()", 
PK_NAME);
-        checkQueryPlan(conn, "SELECT * FROM T WHERE ID > RANDOM_UUID()", 
PK_NAME);
-        checkQueryPlan(conn, "SELECT * FROM T ORDER BY ID", PK_NAME);
-
-        checkQueryPlan(conn, "SELECT * FROM T WHERE STR IS NULL", 
STR_IDX_NAME);
-        checkQueryPlan(conn, "SELECT * FROM T WHERE STR = 'aaaa'", 
STR_IDX_NAME);
-        checkQueryPlan(conn, "SELECT * FROM T WHERE STR > 'aaaa'", 
STR_IDX_NAME);
-        checkQueryPlan(conn, "SELECT * FROM T ORDER BY STR DESC", 
STR_IDX_NAME);
-
-        checkQueryPlan(conn, "SELECT * FROM T WHERE X IS NULL", 
NON_UNIQUE_IDX_NAME);
-        checkQueryPlan(conn, "SELECT * FROM T WHERE X = 10000", 
NON_UNIQUE_IDX_NAME);
-        checkQueryPlan(conn, "SELECT * FROM T WHERE X > 10000", 
NON_UNIQUE_IDX_NAME);
-        checkQueryPlan(conn, "SELECT * FROM T ORDER BY X DESC", 
NON_UNIQUE_IDX_NAME);
-        checkQueryPlan(conn, "SELECT * FROM T ORDER BY X DESC, T", 
NON_UNIQUE_IDX_NAME);
-
-        checkQueryPlan(conn, "SELECT * FROM T ORDER BY T, X DESC", 
SCAN_IDX_NAME);
-
-        // Simple queries.
-
-        Statement s = conn.createStatement();
-
-        ResultSet rs = s.executeQuery("select id from t where x between 0 and 
100");
-
-        int i = 0;
-        while (rs.next())
-            i++;
-
-        assertEquals(MAX_X + 2, i);
-
-        // -----
-
-        rs = s.executeQuery("select id from t where t is not null");
-
-        i = 0;
-        while (rs.next())
-            i++;
-
-        assertEquals(MAX_X + 2, i);
-
-        // ----
-
-        int cnt = 10 + rnd.nextInt(25);
-
-        long t = System.currentTimeMillis();
-
-        for (i = 0; i < cnt; i++) {
-            id = UUID.randomUUID();
-
-            assertTrue(tbl.doUpdate(row(id, t, id.toString(), 51), false));
-        }
-
-        rs = s.executeQuery("select x, id from t where x = 51 limit " + cnt);
-
-        i = 0;
-
-        while (rs.next()) {
-            assertEquals(51, rs.getInt(1));
-
-            i++;
-        }
-
-        assertEquals(cnt, i);
-    }
-
-    /**
-     * Dumps all table rows for index.
-     *
-     * @param idx Index.
-     */
-    private void dumpRows(GridH2TreeIndex idx) {
-        Iterator<GridH2Row> iter = idx.rows();
-
-        while (iter.hasNext())
-            System.out.println(iter.next().toString());
-    }
-
-    /**
-     * Multithreaded indexes consistency test.
-     *
-     * @throws Exception If failed.
-     */
-    public void testIndexesMultiThreadedConsistency() throws Exception {
-        final int threads = 19;
-        final int iterations = 1500;
-
-        multithreaded(new Callable<Void>() {
-            @Override public Void call() throws Exception {
-                Random rnd = new Random();
-
-                PreparedStatement ps1 = null;
-
-                for (int i = 0; i < iterations; i++) {
-                    UUID id = UUID.randomUUID();
-
-                    int x = rnd.nextInt(50);
-
-                    long t = System.currentTimeMillis();
-
-                    GridH2Row row = row(id, t, rnd.nextBoolean() ? 
id.toString() : UUID.randomUUID().toString(), x);
-
-                    assertTrue(tbl.doUpdate(row, false));
-
-                    if (rnd.nextInt(100) == 0) {
-                        tbl.lock(null, false, false);
-
-                        long cnt = 0;
-
-                        try {
-                            ArrayList<Index> idxs = tbl.getIndexes();
-
-                            // Consistency check.
-                            Set<Row> rowSet = checkIndexesConsistent(idxs, 
null);
-
-                            // Order check.
-                            checkOrdered(idxs);
-
-                            checkIndexesConsistent(idxs, rowSet);
-
-                            cnt = idxs.get(0).getRowCount(null);
-                        }
-                        finally {
-                            tbl.unlock(null);
-                        }
-
-                        // Row count is valid.
-                        ResultSet rs = 
conn.createStatement().executeQuery("select count(*) from t");
-
-                        assertTrue(rs.next());
-
-                        int cnt2 = rs.getInt(1);
-
-                        rs.close();
-
-                        assertTrue(cnt2 + " must be >= " + cnt, cnt2 >= cnt);
-                        assertTrue(cnt2 <= threads * iterations);
-
-                        // Search by ID.
-                        rs = conn.createStatement().executeQuery("select * 
from t where id = '" + id.toString() + "'");
-
-                        assertTrue(rs.next());
-                        assertFalse(rs.next());
-
-                        rs.close();
-
-                        // Scan search.
-                        if (ps1 == null)
-                            ps1 = conn.prepareStatement("select id from t 
where x = ? order by t desc");
-
-                        ps1.setInt(1, x);
-
-                        rs = ps1.executeQuery();
-
-                        for (;;) {
-                            assertTrue(rs.next());
-
-                            if (rs.getObject(1).equals(id))
-                                break;
-                        }
-
-                        rs.close();
-                    }
-                }
-                return null;
-            }
-        }, threads);
-    }
-
-    /**
-     * Run test in endless loop.
-     *
-     * @param args Arguments.
-     * @throws Exception If failed.
-     */
-    @SuppressWarnings("InfiniteLoopStatement")
-    public static void main(String ... args) throws Exception {
-        for (int i = 0;;) {
-            GridH2TableSelfTest t = new GridH2TableSelfTest();
-
-            t.beforeTest();
-
-            t.testDataLoss();
-
-            t.afterTest();
-
-            System.out.println("..." + ++i);
-        }
-    }
-
-    /**
-      * @throws Exception If failed.
-     */
-    public void testRangeQuery() throws Exception {
-        int rows = 3000;
-        int xs = 37;
-
-        long t = System.currentTimeMillis();
-
-        Random rnd = new Random();
-
-        for (int i = 0 ; i < rows; i++) {
-            UUID id = UUID.randomUUID();
-
-            GridH2Row row = row(id, t++, id.toString(), rnd.nextInt(xs));
-
-            assertTrue(tbl.doUpdate(row, false));
-        }
-
-        PreparedStatement ps = conn.prepareStatement("select count(*) from t 
where x = ?");
-
-        int cnt = 0;
-
-        for (int x = 0; x < xs; x++) {
-            ps.setInt(1, x);
-
-            ResultSet rs = ps.executeQuery();
-
-            assertTrue(rs.next());
-
-            cnt += rs.getInt(1);
-        }
-
-        assertEquals(rows, cnt);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testDataLoss() throws Exception {
-        final int threads = 37;
-        final int iterations = 15000;
-
-        final AtomicInteger cntr = new AtomicInteger();
-
-        final UUID[] ids = new UUID[threads * iterations];
-
-        for (int i = 0; i < ids.length; i++)
-            ids[i] = UUID.randomUUID();
-
-        final long t = System.currentTimeMillis();
-
-        final AtomicInteger deleted = new AtomicInteger();
-
-        multithreaded(new Callable<Void>() {
-            @Override public Void call() throws Exception {
-                Random rnd = new Random();
-
-                int offset = cntr.getAndIncrement() * iterations;
-
-                synchronized (ids[offset]) {
-                    for (int i = 0; i < iterations; i++) {
-                        UUID id = ids[offset + i];
-
-                        int x = rnd.nextInt(50);
-
-                        GridH2Row row = row(id, t, id.toString(), x);
-
-                        assertTrue(tbl.doUpdate(row, false));
-                    }
-                }
-
-                offset = (offset + iterations) % ids.length;
-
-                synchronized (ids[offset]) {
-                    for (int i = 0; i < iterations; i += 2) {
-                        UUID id = ids[offset + i];
-
-                        int x = rnd.nextInt(50);
-
-                        GridH2Row row = row(id, t, id.toString(), x);
-
-                        if (tbl.doUpdate(row, true))
-                            deleted.incrementAndGet();
-                    }
-                }
-
-                return null;
-            }
-        }, threads);
-
-        assertTrue(deleted.get() > 0);
-
-        PreparedStatement p = conn.prepareStatement("select count(*) from t 
where id = ?");
-
-        for (int i = 1; i < ids.length; i += 2) {
-            p.setObject(1, ids[i]);
-
-            ResultSet rs = p.executeQuery();
-
-            assertTrue(rs.next());
-
-            assertEquals(1, rs.getInt(1));
-        }
-
-        Statement s = conn.createStatement();
-
-        ResultSet rs = s.executeQuery("select count(*) from t");
-
-        assertTrue(rs.next());
-
-        assertEquals(ids.length - deleted.get(), rs.getInt(1));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testRebuildIndexes() throws Exception {
-        ArrayList<GridH2IndexBase> idxsBefore = tbl.indexes();
-
-        assertEquals(3, idxsBefore.size());
-
-        Random rnd = new Random();
-
-        for (int i = 0; i < MAX_X; i++) {
-            UUID id = UUID.randomUUID();
-
-            GridH2Row row = row(id, System.currentTimeMillis(), 
rnd.nextBoolean() ? id.toString() :
-                    UUID.randomUUID().toString(), rnd.nextInt(100));
-
-            tbl.doUpdate(row, false);
-        }
-
-        for (GridH2IndexBase idx : idxsBefore)
-            assertEquals(MAX_X, idx.getRowCountApproximation());
-
-        tbl.rebuildIndexes();
-
-        ArrayList<GridH2IndexBase> idxsAfter = tbl.indexes();
-
-        assertEquals(3, idxsAfter.size());
-
-        for (int i = 0; i < 3; i++) {
-            GridH2IndexBase idxBefore = idxsBefore.get(i);
-            GridH2IndexBase idxAfter = idxsAfter.get(i);
-
-            assertNotSame(idxBefore, idxAfter);
-            assertEquals(idxBefore.getName(), idxAfter.getName());
-            assertSame(idxBefore.getTable(), idxAfter.getTable());
-            assertEquals(idxBefore.getRowCountApproximation(), 
idxAfter.getRowCountApproximation());
-            assertEquals(idxBefore.getIndexType().isUnique(), 
idxAfter.getIndexType().isUnique());
-            Assert.assertArrayEquals(idxBefore.getColumns(), 
idxAfter.getColumns());
-        }
-    }
-
-    /**
-     * Check query plan to correctly select index.
-     *
-     * @param conn Connection.
-     * @param sql Select.
-     * @param search Search token in result.
-     * @throws SQLException If failed.
-     */
-    private void checkQueryPlan(Connection conn, String sql, String search) 
throws SQLException {
-
-        try (Statement s = conn.createStatement()) {
-            try (ResultSet r = s.executeQuery("EXPLAIN ANALYZE " + sql)) {
-                assertTrue(r.next());
-
-                String plan = r.getString(1);
-
-                assertTrue("Execution plan for '" + sql + "' query should 
contain '" + search + "'",
-                        plan.contains(search));
-            }
-        }
-    }
-
-    /**
-     * @param idxs Indexes.
-     * @param rowSet Rows.
-     * @return Rows.
-     */
-    private Set<Row> checkIndexesConsistent(ArrayList<Index> idxs, @Nullable 
Set<Row> rowSet) {
-        for (Index idx : idxs) {
-            if (!(idx instanceof GridH2TreeIndex))
-                continue;
-
-            Set<Row> set = new HashSet<>();
-
-            Iterator<GridH2Row> iter = ((GridH2TreeIndex)idx).rows();
-
-            while(iter.hasNext())
-                assertTrue(set.add(iter.next()));
-
-            //((GridH2SnapTreeSet)((GridH2Index)idx).tree).print();
-
-            if (rowSet == null)
-                rowSet = set;
-            else
-                assertEquals(rowSet, set);
-        }
-
-        return rowSet;
-    }
-
-    /**
-     * @param idxs Indexes list.
-     */
-    private void checkOrdered(ArrayList<Index> idxs) {
-        for (Index idx : idxs) {
-            if (!(idx instanceof GridH2TreeIndex))
-                continue;
-
-            GridH2TreeIndex h2Idx = (GridH2TreeIndex)idx;
-
-            checkOrdered(h2Idx, h2Idx);
-        }
-    }
-
-    /**
-     * @param idx Index.
-     * @param cmp Comparator.
-     */
-    private void checkOrdered(GridH2TreeIndex idx, Comparator<? super 
GridH2Row> cmp) {
-        Iterator<GridH2Row> rows = idx.rows();
-
-        GridH2Row min = null;
-
-        while (rows.hasNext()) {
-            GridH2Row row = rows.next();
-
-            assertNotNull(row);
-
-            assertFalse("Incorrect row order in index: " + idx + "\n min: " + 
min + "\n row: " + row,
-                min != null && cmp.compare(min, row) > 0);
-
-            min = row;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/922a2bab/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/opt/GridLuceneIndexLoadTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/opt/GridLuceneIndexLoadTest.java
 
b/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/opt/GridLuceneIndexLoadTest.java
deleted file mode 100644
index 48767e4..0000000
--- 
a/modules/indexing/src/test/java/org/gridgain/grid/spi/indexing/h2/opt/GridLuceneIndexLoadTest.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/* @java.file.header */
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.gridgain.grid.spi.indexing.h2.opt;
-
-import org.apache.ignite.marshaller.optimized.*;
-import org.apache.ignite.spi.*;
-import org.apache.ignite.spi.indexing.*;
-import org.gridgain.grid.*;
-import org.gridgain.grid.util.typedef.*;
-
-import java.io.*;
-import java.util.*;
-
-/**
- *
- */
-public class GridLuceneIndexLoadTest {
-    /**
-     * @param args Arguments.
-     */
-    @SuppressWarnings("ZeroLengthArrayAllocation")
-    public static void main(String ... args) throws IgniteSpiException, 
FileNotFoundException {
-        final IgniteOptimizedMarshaller m = new IgniteOptimizedMarshaller();
-
-        IndexingTypeDescriptor desc = new IndexingTypeDescriptor() {
-            @Override public String name() {
-                return "StrType";
-            }
-
-            @Override public Map<String, Class<?>> valueFields() {
-                throw new IllegalStateException();
-            }
-
-            @Override public Map<String, Class<?>> keyFields() {
-                throw new IllegalStateException();
-            }
-
-            @Override public <T> T value(Object obj, String field) {
-                throw new IllegalStateException();
-            }
-
-            @Override public Map<String, IndexDescriptor> indexes() {
-                return Collections.<String, 
IndexDescriptor>singletonMap("txt_idx", new IndexDescriptor() {
-                    @Override public Collection<String> fields() {
-                        return Collections.emptyList();
-                    }
-
-                    @Override public boolean descending(String field) {
-                        return false;
-                    }
-
-                    @Override public IndexType type() {
-                        return IndexType.FULLTEXT;
-                    }
-                });
-            }
-
-            @Override public Class<?> valueClass() {
-                return String.class;
-            }
-
-            @Override public Class<?> keyClass() {
-                return Integer.class;
-            }
-
-            @Override public boolean valueTextIndex() {
-                return true;
-            }
-        };
-
-        GridLuceneIndex idx = new GridLuceneIndex(new IndexingMarshaller() {
-            @Override public <T> IndexingEntity<T> unmarshal(byte[] bytes) 
throws IgniteSpiException {
-                try {
-                    return new IndexingEntityAdapter<>(m.<T>unmarshal(bytes, 
null), bytes);
-                }
-                catch (GridException e) {
-                    throw new IgniteSpiException(e);
-                }
-            }
-
-            @Override public byte[] marshal(IndexingEntity<?> entity) throws 
IgniteSpiException {
-                try {
-                    return m.marshal(entity.value());
-                }
-                catch (GridException e) {
-                    throw new IgniteSpiException(e);
-                }
-            }
-        }, null, "spac", desc, false);
-
-        ArrayList<String> ws = 
words("C:\\Users\\svladykin\\YandexDisk\\www\\CSW07-british-dict");
-
-        byte[] ver = new byte[0];
-
-        Random rnd = new Random();
-
-        long begin = System.currentTimeMillis();
-
-        for (int i = 0, len = 10000000 ; i < len; i++) {
-            idx.store(new IndexingEntityAdapter<>(i, null),
-                new IndexingEntityAdapter<Object>(sentence(rnd, ws), null),
-                ver, 0L);
-
-            if (i % 10000 == 0) {
-                long time = System.currentTimeMillis();
-
-                X.println(i + " " + (time - begin) + "ms " + 
GridLuceneFile.filesCnt.get());
-
-                begin = time;
-            }
-        }
-    }
-
-    /**
-     * @param rnd Random.
-     * @param ws Words.
-     * @return Sentence.
-     */
-    static String sentence(Random rnd, ArrayList<String> ws) {
-        StringBuilder b = new StringBuilder();
-
-        for (int i = 0, wordCnt = 1 + rnd.nextInt(8); i < wordCnt; i++) {
-            if (i != 0)
-                b.append(' ');
-
-            b.append(ws.get(rnd.nextInt(ws.size())));
-        }
-
-        return b.toString();
-    }
-
-    /**
-     * @param file File.
-     * @return Words list.
-     * @throws FileNotFoundException If failed.
-     */
-    static ArrayList<String> words(String file) throws FileNotFoundException {
-        Scanner scan = new Scanner(new File(file));
-
-        ArrayList<String> res = new ArrayList<>(270000);
-
-        while (scan.hasNextLine()) {
-            String line = scan.nextLine();
-
-            int space = line.indexOf(' ');
-
-            if (space > 0)
-                line = line.substring(0, space);
-
-            res.add(line.toLowerCase());
-        }
-
-        return res;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/922a2bab/modules/indexing/src/test/java/org/gridgain/loadtests/h2indexing/GridH2IndexingSpiLoadTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/gridgain/loadtests/h2indexing/GridH2IndexingSpiLoadTest.java
 
b/modules/indexing/src/test/java/org/gridgain/loadtests/h2indexing/GridH2IndexingSpiLoadTest.java
deleted file mode 100644
index c367463..0000000
--- 
a/modules/indexing/src/test/java/org/gridgain/loadtests/h2indexing/GridH2IndexingSpiLoadTest.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/* @java.file.header */
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.gridgain.loadtests.h2indexing;
-
-import org.apache.ignite.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.marshaller.optimized.*;
-import org.gridgain.grid.*;
-import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.query.*;
-import org.apache.ignite.spi.discovery.tcp.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.gridgain.grid.spi.indexing.h2.*;
-import org.gridgain.grid.util.typedef.*;
-import org.gridgain.grid.util.typedef.internal.*;
-
-import java.io.*;
-import java.util.*;
-import java.util.concurrent.atomic.*;
-
-import static org.apache.ignite.events.IgniteEventType.*;
-import static org.gridgain.grid.cache.GridCacheDistributionMode.*;
-import static org.gridgain.grid.cache.GridCacheWriteSynchronizationMode.*;
-
-/**
- * Indexing performance test.
- */
-public class GridH2IndexingSpiLoadTest {
-    /**
-     * Gets property as {@code int}.
-     *
-     * @param p Properties.
-     * @param key Key.
-     * @param dflt Default value.
-     * @return Value for key.
-     */
-    private static int getInt(Properties p, String key, int dflt) {
-        String val = p.getProperty(key);
-
-        return val == null ? dflt : Integer.parseInt(val);
-    }
-
-    /**
-     * Gets property as long.
-     *
-     * @param p Properties.
-     * @param key Key.
-     * @param dflt Default value.
-     * @return Value for key.
-     */
-    private static long getLong(Properties p, String key, long dflt) {
-        String val = p.getProperty(key);
-
-        return val == null ? dflt : Long.parseLong(val);
-    }
-
-    /**
-     * Loads configuration for test.
-     *
-     * @return Properties.
-     * @throws IOException if failed.
-     */
-    private static Properties loadProperties() throws IOException {
-        Properties p = new Properties();
-
-        File propsFile = new File("idx-test.properties");
-
-        if (propsFile.exists() && propsFile.isFile())
-            p.load(new FileReader(propsFile));
-        else
-            System.out.println("Properties file not found.");
-
-        return p;
-    }
-
-    /**
-     * Main method.
-     *
-     * @param args Arguments.
-     * @throws GridException If failed.
-     * @throws IOException If failed.
-     */
-    @SuppressWarnings("InfiniteLoopStatement")
-    public static void main(String...args) throws GridException, IOException {
-        final Properties p = loadProperties();
-
-        final int MAX_SIZE = getInt(p, "max-entries-count", 500000);
-        final int MAX_NAMES = getInt(p, "max-names-count", 100);
-
-        IgniteConfiguration c = new IgniteConfiguration();
-
-        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
-        discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
-
-        c.setDiscoverySpi(discoSpi);
-
-        IgniteOptimizedMarshaller m = new IgniteOptimizedMarshaller();
-
-        m.setClassNames(F.asList(GridTestEntity.class.getName()));
-
-        c.setMarshaller(m);
-
-        GridH2IndexingSpi indexing = new GridH2IndexingSpi();
-
-        long offheap = getLong(p, "offheap-size", 3000000000L);
-
-        if (1 == getInt(p, "offheap-enabled", 1))
-            indexing.setMaxOffHeapMemory(offheap);
-
-        boolean enableIndexing = 1 == getInt(p, "indexing-enabled", 1);
-
-        if (enableIndexing)
-            c.setIndexingSpi(indexing);
-
-        GridCacheConfiguration cc = new GridCacheConfiguration();
-
-        cc.setName("local");
-        cc.setCacheMode(GridCacheMode.LOCAL);
-        cc.setStartSize(MAX_SIZE);
-        cc.setWriteSynchronizationMode(FULL_SYNC);
-       // TODO enable evictions
-//        cc.setEvictionPolicy(new GridCacheFifoEvictionPolicy(getInt(p, 
"not-evict-count", 100000)));
-        cc.setQueryIndexEnabled(enableIndexing);
-        cc.setDistributionMode(PARTITIONED_ONLY);
-        cc.setStoreValueBytes(false);
-        cc.setSwapEnabled(false);
-        cc.setOffHeapMaxMemory(0);
-
-        c.setCacheConfiguration(cc);
-        c.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, 
EVT_JOB_MAPPED);
-
-        final Ignite g = G.start(c);
-
-        final GridCache<Long, GridTestEntity> cache = g.cache("local");
-
-        Random rnd = new Random();
-
-        for (int i = 0; i < MAX_SIZE; i++) {
-            if (rnd.nextBoolean())
-                cache.put((long)i, new 
GridTestEntity(Integer.toHexString(rnd.nextInt(MAX_NAMES)), new Date()));
-
-            if (i % 10000 == 0)
-                System.out.println(i);
-        }
-
-        List<Runner> rs = F.asList(
-            new Runner("put", 1000, getInt(p, "put-threads", 8)) {
-                @Override
-                protected void doRun(Random rnd) throws Exception {
-                    cache.put((long)rnd.nextInt(MAX_SIZE), new 
GridTestEntity(Integer.toHexString(rnd.nextInt(MAX_NAMES)),
-                        null));
-                }
-            }.start(),
-
-            new Runner("remove", 1000, getInt(p, "remove-threads", 2)) {
-                @Override
-                protected void doRun(Random rnd) throws Exception {
-                    cache.remove((long)rnd.nextInt(MAX_SIZE));
-                }
-            }.start(),
-
-            new Runner("query", 10, getInt(p, "query-threads", 8)) {
-                @Override
-                protected void doRun(Random rnd) throws Exception {
-                    GridCacheQuery<Map.Entry<Long, GridTestEntity>> qry = 
cache.queries().createSqlQuery(
-                        GridTestEntity.class, "name = ?");
-
-                    
qry.execute(Integer.toHexString(rnd.nextInt(MAX_NAMES))).get();
-
-//                    U.sleep(getInt(p, "query-sleep-time", 25));
-                }
-            }.start());
-
-        for(;;) {
-            U.sleep(getInt(p, "print-period", 3000));
-
-            for (Runner r : rs)
-                r.print();
-
-            long bytes = indexing.getAllocatedOffHeapMemory();
-
-            System.out.println("offheap bytes: " + bytes);
-
-            System.out.println();
-        }
-    }
-
-    /**
-     * Runs job in loop.
-     */
-    private abstract static class Runner implements Runnable {
-        /** */
-        private final String name;
-
-        /** */
-        private final int iters;
-
-        /** */
-        private final int threads;
-
-        /** */
-        private AtomicLong cntr = new AtomicLong();
-
-        /** */
-        private long lastPrintTime;
-        /**
-         * Constructor.
-         *
-         * @param name Name.
-         * @param iters Iterations count to measure.
-         * @param threads Threads.
-         */
-        protected Runner(String name, int iters, int threads) {
-            this.name = name;
-            this.iters = iters;
-            this.threads = threads;
-        }
-
-        /**
-         * Start runner.
-         *
-         * @return Self.
-         */
-        Runner start() {
-            Thread[] ths = new Thread[threads];
-
-            for (int i = 0; i < threads; i++) {
-                ths[i] = new Thread(this, name + "-" + i);
-
-                ths[i].setDaemon(true);
-
-                ths[i].start();
-            }
-
-            lastPrintTime = System.currentTimeMillis();
-
-            return this;
-        }
-
-        /** */
-        @SuppressWarnings("InfiniteLoopStatement")
-        @Override public void run() {
-            Random rnd = new Random();
-
-            try {
-                for (;;) {
-                    for (int i = 0; i < iters; i++)
-                        doRun(rnd);
-
-                    cntr.addAndGet(iters);
-                }
-            }
-            catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-
-        /**
-         * Print stats.
-         */
-        void print() {
-            long cnt = cntr.get();
-            long time = System.currentTimeMillis();
-
-            X.println("-- " + name + ": " + (cnt * 1000 / (time - 
lastPrintTime)) + " op/sec");
-
-            lastPrintTime = time;
-
-            cntr.addAndGet(-cnt);
-        }
-
-        /**
-         * Do the job.
-         *
-         * @param rnd Random for current thread.
-         * @throws Exception If failed.
-         */
-        protected abstract void doRun(Random rnd) throws Exception;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/922a2bab/modules/indexing/src/test/java/org/gridgain/testsuites/bamboo/GridH2IndexingSpiTestSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/gridgain/testsuites/bamboo/GridH2IndexingSpiTestSuite.java
 
b/modules/indexing/src/test/java/org/gridgain/testsuites/bamboo/GridH2IndexingSpiTestSuite.java
index b0aedb6..c1d1b1c 100644
--- 
a/modules/indexing/src/test/java/org/gridgain/testsuites/bamboo/GridH2IndexingSpiTestSuite.java
+++ 
b/modules/indexing/src/test/java/org/gridgain/testsuites/bamboo/GridH2IndexingSpiTestSuite.java
@@ -12,8 +12,8 @@ package org.gridgain.testsuites.bamboo;
 import junit.framework.*;
 import org.gridgain.grid.kernal.processors.cache.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.near.*;
-import org.gridgain.grid.spi.indexing.h2.*;
-import org.gridgain.grid.spi.indexing.h2.opt.*;
+import org.gridgain.grid.kernal.processors.query.h2.*;
+import org.gridgain.grid.kernal.processors.query.h2.opt.*;
 
 /**
  * H2 indexing SPI tests.
@@ -30,18 +30,16 @@ public class GridH2IndexingSpiTestSuite extends TestSuite {
         suite.addTest(new TestSuite(GridH2TableSelfTest.class));
 
         // H2 Indexing in-memory.
-        suite.addTest(new 
TestSuite(GridH2IndexingSpiInMemStartStopSelfTest.class));
-        suite.addTest(new TestSuite(GridH2IndexingSpiInMemSelfTest.class));
+        suite.addTest(new TestSuite(GridH2IndexingInMemSelfTest.class));
 
         // H2 Off-heap memory.
-        suite.addTest(new 
TestSuite(GridH2IndexingSpiOffheapStartStopSelfTest.class));
-        suite.addTest(new TestSuite(GridH2IndexingSpiOffheapSelfTest.class));
+        suite.addTest(new TestSuite(GridH2IndexingOffheapSelfTest.class));
 
         // Index rebuilding.
         suite.addTest(new TestSuite(GridH2IndexRebuildTest.class));
 
         // Geo.
-        suite.addTestSuite(GridH2IndexingSpiGeoSelfTest.class);
+        suite.addTestSuite(GridH2IndexingGeoSelfTest.class);
 
         // Tests moved to this suite since they require GridH2IndexingSpi.
         suite.addTestSuite(GridCacheOffHeapAndSwapSelfTest.class);

Reply via email to