http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/core/src/test/config/store/jdbc/ignite-type-metadata.xml ---------------------------------------------------------------------- diff --git a/modules/core/src/test/config/store/jdbc/ignite-type-metadata.xml b/modules/core/src/test/config/store/jdbc/ignite-type-metadata.xml deleted file mode 100644 index 3e3d6e0..0000000 --- a/modules/core/src/test/config/store/jdbc/ignite-type-metadata.xml +++ /dev/null @@ -1,276 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- - 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. ---> - -<!-- - XML generated by Apache Ignite Schema Import utility: 02/03/2015 ---> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:util="http://www.springframework.org/schema/util" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/util - http://www.springframework.org/schema/util/spring-util.xsd"> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> - <property name="databaseSchema" value="PUBLIC"/> - <property name="databaseTable" value="ORGANIZATION"/> - <property name="keyType" value="org.apache.ignite.cache.store.jdbc.model.OrganizationKey"/> - <property name="valueType" value="org.apache.ignite.cache.store.jdbc.model.Organization"/> - <property name="keyFields"> - <list> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="ID"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.INTEGER"/> - </property> - <property name="javaName" value="id"/> - <property name="javaType" value="java.lang.Integer"/> - </bean> - </list> - </property> - <property name="valueFields"> - <list> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="ID"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.INTEGER"/> - </property> - <property name="javaName" value="id"/> - <property name="javaType" value="java.lang.Integer"/> - </bean> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="NAME"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.VARCHAR"/> - </property> - <property name="javaName" value="name"/> - <property name="javaType" value="java.lang.String"/> - </bean> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="CITY"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.VARCHAR"/> - </property> - <property name="javaName" value="city"/> - <property name="javaType" value="java.lang.String"/> - </bean> - </list> - </property> - - </bean> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> - <property name="databaseSchema" value="PUBLIC"/> - <property name="databaseTable" value="PERSON"/> - <property name="keyType" value="org.apache.ignite.cache.store.jdbc.model.PersonKey"/> - <property name="valueType" value="org.apache.ignite.cache.store.jdbc.model.Person"/> - <property name="keyFields"> - <list> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="ID"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.INTEGER"/> - </property> - <property name="javaName" value="id"/> - <property name="javaType" value="java.lang.Integer"/> - </bean> - </list> - </property> - <property name="valueFields"> - <list> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="ID"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.INTEGER"/> - </property> - <property name="javaName" value="id"/> - <property name="javaType" value="java.lang.Integer"/> - </bean> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="ORG_ID"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.INTEGER"/> - </property> - <property name="javaName" value="orgId"/> - <property name="javaType" value="java.lang.Integer"/> - </bean> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="NAME"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.VARCHAR"/> - </property> - <property name="javaName" value="name"/> - <property name="javaType" value="java.lang.String"/> - </bean> - </list> - </property> - - </bean> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> - <property name="databaseSchema" value="PUBLIC"/> - <property name="databaseTable" value="PERSON_COMPLEX"/> - <property name="keyType" value="org.apache.ignite.cache.store.jdbc.model.PersonComplexKey"/> - <property name="valueType" value="org.apache.ignite.cache.store.jdbc.model.Person"/> - <property name="keyFields"> - <list> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="ID"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.INTEGER"/> - </property> - <property name="javaName" value="id"/> - <property name="javaType" value="int"/> - </bean> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="ORG_ID"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.INTEGER"/> - </property> - <property name="javaName" value="orgId"/> - <property name="javaType" value="int"/> - </bean> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="CITY_ID"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.INTEGER"/> - </property> - <property name="javaName" value="cityId"/> - <property name="javaType" value="int"/> - </bean> - </list> - </property> - <property name="valueFields"> - <list> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="ID"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.INTEGER"/> - </property> - <property name="javaName" value="id"/> - <property name="javaType" value="java.lang.Integer"/> - </bean> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="ORG_ID"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.INTEGER"/> - </property> - <property name="javaName" value="orgId"/> - <property name="javaType" value="java.lang.Integer"/> - </bean> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="NAME"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.VARCHAR"/> - </property> - <property name="javaName" value="name"/> - <property name="javaType" value="java.lang.String"/> - </bean> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="salary"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.INTEGER"/> - </property> - <property name="javaName" value="salary"/> - <property name="javaType" value="java.lang.Integer"/> - </bean> - </list> - </property> - </bean> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> - <property name="databaseSchema" value="PUBLIC"/> - <property name="databaseTable" value="STRING_ENTRIES"/> - <property name="keyType" value="java.lang.String"/> - <property name="valueType" value="java.lang.String"/> - <property name="keyFields"> - <list> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="KEY"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.VARCHAR"/> - </property> - </bean> - </list> - </property> - <property name="valueFields"> - <list> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="VAL"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.VARCHAR"/> - </property> - </bean> - </list> - </property> - </bean> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> - <property name="databaseSchema" value="PUBLIC"/> - <property name="databaseTable" value="UUID_ENTRIES"/> - <property name="keyType" value="java.util.UUID"/> - <property name="valueType" value="java.util.UUID"/> - <property name="keyFields"> - <list> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="KEY"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.BINARY"/> - </property> - <property name="javaType" value="java.util.UUID"/> - </bean> - </list> - </property> - <property name="valueFields"> - <list> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="VAL"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.BINARY"/> - </property> - <property name="javaType" value="java.util.UUID"/> - </bean> - </list> - </property> - </bean> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> - <property name="databaseSchema" value="PUBLIC"/> - <property name="databaseTable" value="TIMESTAMP_ENTRIES"/> - <property name="keyType" value="java.sql.Timestamp"/> - <property name="valueType" value="java.lang.Integer"/> - <property name="keyFields"> - <list> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="KEY"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.TIMESTAMP"/> - </property> - <property name="javaType" value="java.sql.Timestamp"/> - </bean> - </list> - </property> - <property name="valueFields"> - <list> - <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="VAL"/> - <property name="databaseType"> - <util:constant static-field="java.sql.Types.INTEGER"/> - </property> - <property name="javaType" value="java.lang.Integer"/> - </bean> - </list> - </property> - </bean> -</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java index 89841f8..e7a4af0 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java @@ -32,7 +32,6 @@ import java.util.Random; import java.util.concurrent.Callable; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.cache.CacheTypeMetadata; import org.apache.ignite.cache.store.jdbc.model.Gender; import org.apache.ignite.cache.store.jdbc.model.Organization; import org.apache.ignite.cache.store.jdbc.model.OrganizationKey; @@ -65,7 +64,7 @@ import static org.apache.ignite.testframework.GridTestUtils.runMultiThreadedAsyn public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T extends CacheAbstractJdbcStore> extends GridCommonAbstractTest { /** Default config with mapping. */ - private static final String DFLT_MAPPING_CONFIG = "modules/core/src/test/config/store/jdbc/ignite-type-metadata.xml"; + private static final String DFLT_MAPPING_CONFIG = "modules/core/src/test/config/store/jdbc/ignite-jdbc-type.xml"; /** Database connection URL. */ protected static final String DFLT_CONN_URL = "jdbc:h2:mem:autoCacheStore;DB_CLOSE_DELAY=-1"; @@ -85,6 +84,40 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T extends Cach /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { store = store(); + + URL cfgUrl; + + try { + cfgUrl = new URL(DFLT_MAPPING_CONFIG); + } + catch (MalformedURLException ignore) { + cfgUrl = U.resolveIgniteUrl(DFLT_MAPPING_CONFIG); + } + + if (cfgUrl == null) + throw new Exception("Failed to resolve metadata path: " + DFLT_MAPPING_CONFIG); + + try { + GenericApplicationContext springCtx = new GenericApplicationContext(); + + new XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(new UrlResource(cfgUrl)); + + springCtx.refresh(); + + Collection<JdbcType> types = new ArrayList<>(springCtx.getBeansOfType(JdbcType.class).values()); + + store.setTypes(types.toArray(new JdbcType[types.size()])); + } + catch (BeansException e) { + if (X.hasCause(e, ClassNotFoundException.class)) + throw new IgniteCheckedException("Failed to instantiate Spring XML application context " + + "(make sure all classes used in Spring configuration are present at CLASSPATH) " + + "[springUrl=" + cfgUrl + ']', e); + else + throw new IgniteCheckedException("Failed to instantiate Spring XML application context [springUrl=" + + cfgUrl + ", err=" + e.getMessage() + ']', e); + } + } /** {@inheritDoc} */ @@ -151,40 +184,8 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T extends Cach cc.setSwapEnabled(false); cc.setWriteBehindEnabled(false); - URL cfgUrl; - - try { - cfgUrl = new URL(DFLT_MAPPING_CONFIG); - } - catch (MalformedURLException ignore) { - cfgUrl = U.resolveIgniteUrl(DFLT_MAPPING_CONFIG); - } - - if (cfgUrl == null) - throw new Exception("Failed to resolve metadata path: " + DFLT_MAPPING_CONFIG); - - try { - GenericApplicationContext springCtx = new GenericApplicationContext(); - - new XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(new UrlResource(cfgUrl)); - - springCtx.refresh(); - - Collection<CacheTypeMetadata> tp = new ArrayList<>(springCtx.getBeansOfType(CacheTypeMetadata.class).values()); - - cc.setTypeMetadata(tp); - } - catch (BeansException e) { - if (X.hasCause(e, ClassNotFoundException.class)) - throw new IgniteCheckedException("Failed to instantiate Spring XML application context " + - "(make sure all classes used in Spring configuration are present at CLASSPATH) " + - "[springUrl=" + cfgUrl + ']', e); - else - throw new IgniteCheckedException("Failed to instantiate Spring XML application context [springUrl=" + - cfgUrl + ", err=" + e.getMessage() + ']', e); - } - cc.setCacheStoreFactory(singletonFactory(store)); + cc.setReadThrough(true); cc.setWriteThrough(true); cc.setLoadPreviousValue(true); http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryDuplicateIndexObjectsAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryDuplicateIndexObjectsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryDuplicateIndexObjectsAbstractSelfTest.java deleted file mode 100644 index ccfe68b..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridBinaryDuplicateIndexObjectsAbstractSelfTest.java +++ /dev/null @@ -1,161 +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.binary; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.CacheTypeMetadata; -import org.apache.ignite.cache.query.SqlFieldsQuery; -import org.apache.ignite.configuration.BinaryConfiguration; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.binary.BinaryMarshaller; -import org.apache.ignite.binary.BinaryObject; - -/** - * Tests that binary object is the same in cache entry and in index. - */ -public abstract class GridBinaryDuplicateIndexObjectsAbstractSelfTest extends GridCacheAbstractSelfTest { - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 1; - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - BinaryConfiguration bCfg = new BinaryConfiguration(); - - bCfg.setClassNames(Collections.singletonList(TestBinary.class.getName())); - - cfg.setBinaryConfiguration(bCfg); - - cfg.setMarshaller(new BinaryMarshaller()); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { - CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName); - - ccfg.setCopyOnRead(false); - - CacheTypeMetadata meta = new CacheTypeMetadata(); - - meta.setKeyType(Integer.class); - meta.setValueType(TestBinary.class.getName()); - - Map<String, Class<?>> idx = new HashMap<>(); - - idx.put("fieldOne", String.class); - idx.put("fieldTwo", Integer.class); - - meta.setAscendingFields(idx); - - ccfg.setTypeMetadata(Collections.singletonList(meta)); - - return ccfg; - } - - /** {@inheritDoc} */ - @Override public abstract CacheAtomicityMode atomicityMode(); - - /** {@inheritDoc} */ - @Override public abstract CacheMode cacheMode(); - - /** - * @throws Exception If failed. - */ - public void testIndexReferences() throws Exception { - IgniteCache<Integer, TestBinary> cache = grid(0).cache(null); - - String fieldOneVal = "123"; - int fieldTwoVal = 123; - int key = 0; - - cache.put(key, new TestBinary(fieldOneVal, fieldTwoVal)); - - IgniteCache<Integer, BinaryObject> prj = grid(0).cache(null).withKeepBinary(); - - BinaryObject cacheVal = prj.get(key); - - assertEquals(fieldOneVal, cacheVal.field("fieldOne")); - assertEquals(new Integer(fieldTwoVal), cacheVal.field("fieldTwo")); - - List<?> row = F.first(prj.query(new SqlFieldsQuery("select _val from " + - "TestBinary where _key = ?").setArgs(key)).getAll()); - - assertEquals(1, row.size()); - - BinaryObject qryVal = (BinaryObject)row.get(0); - - assertEquals(fieldOneVal, qryVal.field("fieldOne")); - assertEquals(new Integer(fieldTwoVal), qryVal.field("fieldTwo")); - assertSame(cacheVal, qryVal); - } - - /** - * Test binary object. - */ - private static class TestBinary { - /** */ - private String fieldOne; - - /** */ - private int fieldTwo; - - /** - * - */ - private TestBinary() { - // No-op. - } - - /** - * @param fieldOne Field one. - * @param fieldTwo Field two. - */ - private TestBinary(String fieldOne, int fieldTwo) { - this.fieldOne = fieldOne; - this.fieldTwo = fieldTwo; - } - - /** - * @return Field one. - */ - public String fieldOne() { - return fieldOne; - } - - /** - * @return Field two. - */ - public int fieldTwo() { - return fieldTwo; - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/distributed/dht/GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/distributed/dht/GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/distributed/dht/GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest.java deleted file mode 100644 index 459d0ee..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/distributed/dht/GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest.java +++ /dev/null @@ -1,38 +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.binary.distributed.dht; - -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.internal.processors.cache.binary.GridBinaryDuplicateIndexObjectsAbstractSelfTest; - -/** - * Test PARTITIONED ATOMIC. - */ -public class GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest extends - GridBinaryDuplicateIndexObjectsAbstractSelfTest { - /** {@inheritDoc} */ - @Override public CacheAtomicityMode atomicityMode() { - return CacheAtomicityMode.ATOMIC; - } - - /** {@inheritDoc} */ - @Override public CacheMode cacheMode() { - return CacheMode.PARTITIONED; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/distributed/dht/GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/distributed/dht/GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/distributed/dht/GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest.java deleted file mode 100644 index e319fe4..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/distributed/dht/GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest.java +++ /dev/null @@ -1,41 +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.binary.distributed.dht; - -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.internal.processors.cache.binary.GridBinaryDuplicateIndexObjectsAbstractSelfTest; - -import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; -import static org.apache.ignite.cache.CacheMode.PARTITIONED; - -/** - * Test PARTITIONED and TRANSACTIONAL. - */ -public class GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest extends - GridBinaryDuplicateIndexObjectsAbstractSelfTest { - /** {@inheritDoc} */ - @Override public CacheAtomicityMode atomicityMode() { - return TRANSACTIONAL; - } - - /** {@inheritDoc} */ - @Override public CacheMode cacheMode() { - return PARTITIONED; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinarySerializationQuerySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinarySerializationQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinarySerializationQuerySelfTest.java index d205065..2b2e9de 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinarySerializationQuerySelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinarySerializationQuerySelfTest.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.cache; +import java.util.Collections; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.Ignition; @@ -29,8 +30,9 @@ import org.apache.ignite.binary.Binarylizable; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.CacheRebalanceMode; -import org.apache.ignite.cache.CacheTypeMetadata; import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.cache.QueryIndex; import org.apache.ignite.cache.query.SqlFieldsQuery; import org.apache.ignite.cache.query.SqlQuery; import org.apache.ignite.configuration.BinaryConfiguration; @@ -52,7 +54,6 @@ import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.ArrayList; -import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -114,15 +115,15 @@ public class BinarySerializationQuerySelfTest extends GridCommonAbstractTest { cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC); - List<CacheTypeMetadata> metas = new ArrayList<>(); + List<QueryEntity> queryEntities = new ArrayList<>(); - metas.add(metaForClass(EntityPlain.class)); - metas.add(metaForClass(EntitySerializable.class)); - metas.add(metaForClass(EntityExternalizable.class)); - metas.add(metaForClass(EntityBinarylizable.class)); - metas.add(metaForClass(EntityWriteReadObject.class)); + queryEntities.add(entityForClass(EntityPlain.class)); + queryEntities.add(entityForClass(EntitySerializable.class)); + queryEntities.add(entityForClass(EntityExternalizable.class)); + queryEntities.add(entityForClass(EntityBinarylizable.class)); + queryEntities.add(entityForClass(EntityWriteReadObject.class)); - cacheCfg.setTypeMetadata(metas); + cacheCfg.setQueryEntities(queryEntities); cfg.setCacheConfiguration(cacheCfg); @@ -137,14 +138,13 @@ public class BinarySerializationQuerySelfTest extends GridCommonAbstractTest { * @param cls Class. * @return Type metadata. */ - private static CacheTypeMetadata metaForClass(Class cls) { - CacheTypeMetadata meta = new CacheTypeMetadata(); + private static QueryEntity entityForClass(Class cls) { + QueryEntity entity = new QueryEntity(Integer.class.getName(), cls.getName()); - meta.setKeyType(Integer.class); - meta.setValueType(cls); - meta.setAscendingFields(Collections.<String, Class<?>>singletonMap("val", Integer.class)); + entity.addQueryField("val", Integer.class.getName(), null); + entity.setIndexes(Collections.singletonList(new QueryIndex("val", true))); - return meta; + return entity; } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridBinaryDuplicateIndexObjectsAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridBinaryDuplicateIndexObjectsAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridBinaryDuplicateIndexObjectsAbstractSelfTest.java new file mode 100644 index 0000000..e257378 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridBinaryDuplicateIndexObjectsAbstractSelfTest.java @@ -0,0 +1,159 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.cache.QueryIndex; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.BinaryConfiguration; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.binary.BinaryMarshaller; +import org.apache.ignite.binary.BinaryObject; + +/** + * Tests that binary object is the same in cache entry and in index. + */ +public abstract class GridBinaryDuplicateIndexObjectsAbstractSelfTest extends GridCacheAbstractSelfTest { + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 1; + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + BinaryConfiguration bCfg = new BinaryConfiguration(); + + bCfg.setClassNames(Collections.singletonList(TestBinary.class.getName())); + + cfg.setBinaryConfiguration(bCfg); + + cfg.setMarshaller(new BinaryMarshaller()); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception { + CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName); + + ccfg.setCopyOnRead(false); + + QueryEntity queryEntity = new QueryEntity(Integer.class.getName(), TestBinary.class.getName()); + + queryEntity.addQueryField("fieldOne", String.class.getName(), null); + queryEntity.addQueryField("fieldTwo", Integer.class.getName(), null); + + queryEntity.setIndexes(Arrays.asList( + new QueryIndex("fieldOne", true), + new QueryIndex("fieldTwo", true))); + + ccfg.setQueryEntities(Collections.singletonList(queryEntity)); + + return ccfg; + } + + /** {@inheritDoc} */ + @Override public abstract CacheAtomicityMode atomicityMode(); + + /** {@inheritDoc} */ + @Override public abstract CacheMode cacheMode(); + + /** + * @throws Exception If failed. + */ + public void testIndexReferences() throws Exception { + IgniteCache<Integer, TestBinary> cache = grid(0).cache(null); + + String fieldOneVal = "123"; + int fieldTwoVal = 123; + int key = 0; + + cache.put(key, new TestBinary(fieldOneVal, fieldTwoVal)); + + IgniteCache<Integer, BinaryObject> prj = grid(0).cache(null).withKeepBinary(); + + BinaryObject cacheVal = prj.get(key); + + assertEquals(fieldOneVal, cacheVal.field("fieldOne")); + assertEquals(new Integer(fieldTwoVal), cacheVal.field("fieldTwo")); + + List<?> row = F.first(prj.query(new SqlFieldsQuery("select _val from " + + "TestBinary where _key = ?").setArgs(key)).getAll()); + + assertEquals(1, row.size()); + + BinaryObject qryVal = (BinaryObject)row.get(0); + + assertEquals(fieldOneVal, qryVal.field("fieldOne")); + assertEquals(new Integer(fieldTwoVal), qryVal.field("fieldTwo")); + assertSame(cacheVal, qryVal); + } + + /** + * Test binary object. + */ + private static class TestBinary { + /** */ + private String fieldOne; + + /** */ + private int fieldTwo; + + /** + * + */ + private TestBinary() { + // No-op. + } + + /** + * @param fieldOne Field one. + * @param fieldTwo Field two. + */ + private TestBinary(String fieldOne, int fieldTwo) { + this.fieldOne = fieldOne; + this.fieldTwo = fieldTwo; + } + + /** + * @return Field one. + */ + public String fieldOne() { + return fieldOne; + } + + /** + * @return Field two. + */ + public int fieldTwo() { + return fieldTwo; + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectCacheTypeMetadataTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectCacheTypeMetadataTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectCacheTypeMetadataTest.java deleted file mode 100644 index 9695ffb..0000000 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectCacheTypeMetadataTest.java +++ /dev/null @@ -1,72 +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 java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import org.apache.ignite.cache.CacheTypeMetadata; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.processors.query.QueryUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -/** - * A test for {@link CacheTypeMetadata} initialization with incorrect query field name - */ -public class IncorrectCacheTypeMetadataTest extends GridCommonAbstractTest { - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - CacheConfiguration dfltCacheCfg = defaultCacheConfiguration(); - - CacheTypeMetadata cacheTypeMetadata = new CacheTypeMetadata(); - - Map<String, Class<?>> queryFieldsMap = new HashMap<>(); - - queryFieldsMap.put("exceptionOid", Object.class); - - cacheTypeMetadata.setQueryFields(queryFieldsMap); - cacheTypeMetadata.setValueType(Object.class); - - dfltCacheCfg.setTypeMetadata(Collections.singleton(cacheTypeMetadata)); - - cfg.setCacheConfiguration(dfltCacheCfg); - - return cfg; - } - - /** - * Grid must be stopped with property initialization exception. - * - * @throws Exception If failed. - */ - public void testIncorrectQueryField() throws Exception { - try { - startGrid(); - } - catch (Exception exception) { - if (!exception.getMessage().contains( - QueryUtils.propertyInitializationExceptionMessage( - Object.class, Object.class, "exceptionOid", Object.class))) { - fail("property initialization exception must be thrown, but got " + exception.getMessage()); - } - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectQueryEntityTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectQueryEntityTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectQueryEntityTest.java index 9bdadc6..38a02e9 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectQueryEntityTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IncorrectQueryEntityTest.java @@ -27,6 +27,9 @@ import org.apache.ignite.internal.processors.query.QueryUtils; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +/** + * A test for {@link QueryEntity} initialization with incorrect query field name + */ public class IncorrectQueryEntityTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest.java new file mode 100644 index 0000000..d36b794 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.distributed; + +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.internal.processors.cache.GridBinaryDuplicateIndexObjectsAbstractSelfTest; + +/** + * Test PARTITIONED ATOMIC. + */ +public class GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest extends + GridBinaryDuplicateIndexObjectsAbstractSelfTest { + /** {@inheritDoc} */ + @Override public CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.ATOMIC; + } + + /** {@inheritDoc} */ + @Override public CacheMode cacheMode() { + return CacheMode.PARTITIONED; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest.java new file mode 100644 index 0000000..529b556 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.distributed; + +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.internal.processors.cache.GridBinaryDuplicateIndexObjectsAbstractSelfTest; + +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheMode.PARTITIONED; + +/** + * Test PARTITIONED and TRANSACTIONAL. + */ +public class GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest extends + GridBinaryDuplicateIndexObjectsAbstractSelfTest { + /** {@inheritDoc} */ + @Override public CacheAtomicityMode atomicityMode() { + return TRANSACTIONAL; + } + + /** {@inheritDoc} */ + @Override public CacheMode cacheMode() { + return PARTITIONED; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java index 3cb603c..e957f0f 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java @@ -22,8 +22,8 @@ import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.processors.cache.BinarySerializationQuerySelfTest; import org.apache.ignite.internal.processors.cache.BinarySerializationQueryWithReflectiveSerializerSelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheBinaryObjectsScanSelfTest; -import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest; -import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest; import org.apache.ignite.testframework.config.GridTestProperties; /** http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/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 5b74de7..24edd44 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 @@ -68,7 +68,6 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheQueryIndexSelfTest import org.apache.ignite.internal.processors.cache.IgniteCacheQueryLoadSelfTest; import org.apache.ignite.internal.processors.cache.IgniteCacheUpdateSqlQuerySelfTest; import org.apache.ignite.internal.processors.cache.IgniteCrossCachesJoinsQueryTest; -import org.apache.ignite.internal.processors.cache.IncorrectCacheTypeMetadataTest; import org.apache.ignite.internal.processors.cache.IncorrectQueryEntityTest; import org.apache.ignite.internal.processors.cache.QueryEntityCaseMismatchTest; import org.apache.ignite.internal.processors.cache.SqlFieldsQuerySelfTest; @@ -134,7 +133,6 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite { // Config. suite.addTestSuite(IgniteCacheDuplicateEntityConfigurationSelfTest.class); - suite.addTestSuite(IncorrectCacheTypeMetadataTest.class); suite.addTestSuite(IncorrectQueryEntityTest.class); // Queries tests. http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/platforms/cpp/core-test/config/cache-query.xml ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core-test/config/cache-query.xml b/modules/platforms/cpp/core-test/config/cache-query.xml index 036c464..b565822 100644 --- a/modules/platforms/cpp/core-test/config/cache-query.xml +++ b/modules/platforms/cpp/core-test/config/cache-query.xml @@ -46,16 +46,11 @@ </bean> </property> - <property name="typeMetadata"> + <property name="queryEntities"> <list> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> + <bean class="org.apache.ignite.cache.QueryEntity"> <property name="valueType" value="QueryPerson"/> - <property name="ascendingFields"> - <map> - <entry key="age" value="java.lang.Integer"/> - </map> - </property> - <property name="queryFields"> + <property name="fields"> <map> <entry key="name" value="java.lang.String"/> <entry key="age" value="java.lang.Integer"/> @@ -63,9 +58,23 @@ <entry key="recordCreated" value="java.sql.Timestamp"/> </map> </property> - <property name="textFields"> + <property name="indexes"> <list> - <value>name</value> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="fields"> + <map> + <entry key="age" value="true"/> + </map> + </property> + </bean> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="indexType" value="FULLTEXT"/> + <property name="fields"> + <map> + <entry key="name" value="false"/> + </map> + </property> + </bean> </list> </property> </bean> @@ -84,12 +93,12 @@ <property name="partitions" value="256"/> </bean> </property> - - <property name="typeMetadata"> + + <property name="queryEntities"> <list> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> + <bean class="org.apache.ignite.cache.QueryEntity"> <property name="valueType" value="QueryRelation"/> - <property name="queryFields"> + <property name="fields"> <map> <entry key="personId" value="java.lang.Integer"/> <entry key="someVal" value="java.lang.Integer"/> http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml index 72d9d46..5fc973b 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml @@ -38,23 +38,33 @@ <property name="writeSynchronizationMode" value="FULL_SYNC"/> <property name="backups" value="0"/> <property name="startSize" value="10"/> - <property name="typeMetadata"> + + <property name="queryEntities"> <list> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> + <bean class="org.apache.ignite.cache.QueryEntity"> <property name="valueType" value="BinarizableEntry"/> - <property name="ascendingFields"> - <map> - <entry key="val" value="java.lang.Integer"/> - </map> - </property> - <property name="queryFields"> + <property name="fields"> <map> <entry key="val" value="java.lang.Integer"/> </map> </property> - <property name="textFields"> + <property name="indexes"> <list> - <value>val</value> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="fields"> + <map> + <entry key="val" value="true"/> + </map> + </property> + </bean> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="indexType" value="FULLTEXT"/> + <property name="fields"> + <map> + <entry key="val" value="false"/> + </map> + </property> + </bean> </list> </property> </bean> @@ -68,23 +78,33 @@ <property name="writeSynchronizationMode" value="FULL_SYNC"/> <property name="backups" value="1"/> <property name="startSize" value="10"/> - <property name="typeMetadata"> + + <property name="queryEntities"> <list> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> + <bean class="org.apache.ignite.cache.QueryEntity"> <property name="valueType" value="BinarizableEntry"/> - <property name="ascendingFields"> - <map> - <entry key="val" value="java.lang.Integer"/> - </map> - </property> - <property name="queryFields"> + <property name="fields"> <map> <entry key="val" value="java.lang.Integer"/> </map> </property> - <property name="textFields"> + <property name="indexes"> <list> - <value>val</value> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="fields"> + <map> + <entry key="val" value="true"/> + </map> + </property> + </bean> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="indexType" value="FULLTEXT"/> + <property name="fields"> + <map> + <entry key="val" value="false"/> + </map> + </property> + </bean> </list> </property> </bean> @@ -98,23 +118,32 @@ <property name="writeSynchronizationMode" value="FULL_SYNC"/> <property name="backups" value="0"/> <property name="startSize" value="10"/> - <property name="typeMetadata"> + <property name="queryEntities"> <list> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> + <bean class="org.apache.ignite.cache.QueryEntity"> <property name="valueType" value="BinarizableEntry"/> - <property name="ascendingFields"> - <map> - <entry key="val" value="java.lang.Integer"/> - </map> - </property> - <property name="queryFields"> + <property name="fields"> <map> <entry key="val" value="java.lang.Integer"/> </map> </property> - <property name="textFields"> + <property name="indexes"> <list> - <value>val</value> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="fields"> + <map> + <entry key="val" value="true"/> + </map> + </property> + </bean> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="indexType" value="FULLTEXT"/> + <property name="fields"> + <map> + <entry key="val" value="false"/> + </map> + </property> + </bean> </list> </property> </bean> @@ -128,23 +157,32 @@ <property name="writeSynchronizationMode" value="FULL_SYNC"/> <property name="backups" value="1"/> <property name="startSize" value="10"/> - <property name="typeMetadata"> + <property name="queryEntities"> <list> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> + <bean class="org.apache.ignite.cache.QueryEntity"> <property name="valueType" value="BinarizableEntry"/> - <property name="ascendingFields"> - <map> - <entry key="val" value="java.lang.Integer"/> - </map> - </property> - <property name="queryFields"> + <property name="fields"> <map> <entry key="val" value="java.lang.Integer"/> </map> </property> - <property name="textFields"> + <property name="indexes"> <list> - <value>val</value> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="fields"> + <map> + <entry key="val" value="true"/> + </map> + </property> + </bean> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="indexType" value="FULLTEXT"/> + <property name="fields"> + <map> + <entry key="val" value="false"/> + </map> + </property> + </bean> </list> </property> </bean> http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/schema-import/README.txt ---------------------------------------------------------------------- diff --git a/modules/schema-import/README.txt b/modules/schema-import/README.txt index 31a8ff0..ba185b6 100644 --- a/modules/schema-import/README.txt +++ b/modules/schema-import/README.txt @@ -28,12 +28,12 @@ insert into PERSON(id, first_name, last_name, salary) values(6, 'Isaac', 'Newton The Ignite Schema Import utility generates the following artifacts: # Java POJO key and value classes (enter "org.apache.ignite.schema" package name before generation). - # XML CacheTypeMetadata configuration. + # XML QueryEntities configuration. # Java configuration snippet (alternative to XML). After you exit from the wizard, you should: # Copy generated POJO java classes to you project source folder. - # Copy XML declaration of CacheTypeMetadata to your Ignite XML configuration file under appropriate + # Copy XML declaration of QueryEntitres to your Ignite XML configuration file under appropriate CacheConfiguration root. # Setup your Ignite XML configuration file DataSource to your RDBMS system for CacheJdbcPojoStore. # Or paste Java snippet with cache configuration into your Ignite initialization logic. http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/spring/pom.xml ---------------------------------------------------------------------- diff --git a/modules/spring/pom.xml b/modules/spring/pom.xml index 6deb52e..275243f 100644 --- a/modules/spring/pom.xml +++ b/modules/spring/pom.xml @@ -42,6 +42,12 @@ </dependency> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-indexing</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/spring/src/test/java/org/apache/ignite/spring/IgniteExcludeInConfigurationTest.java ---------------------------------------------------------------------- diff --git a/modules/spring/src/test/java/org/apache/ignite/spring/IgniteExcludeInConfigurationTest.java b/modules/spring/src/test/java/org/apache/ignite/spring/IgniteExcludeInConfigurationTest.java index fefcb69..3104b8e 100644 --- a/modules/spring/src/test/java/org/apache/ignite/spring/IgniteExcludeInConfigurationTest.java +++ b/modules/spring/src/test/java/org/apache/ignite/spring/IgniteExcludeInConfigurationTest.java @@ -19,9 +19,10 @@ package org.apache.ignite.spring; import java.net.URL; import java.util.Collection; -import org.apache.ignite.cache.CacheTypeMetadata; +import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.spring.IgniteSpringHelper; +import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; @@ -40,7 +41,7 @@ public class IgniteExcludeInConfigurationTest extends GridCommonAbstractTest { IgniteSpringHelper spring = SPRING.create(false); Collection<IgniteConfiguration> cfgs = spring.loadConfigurations(cfgLocation, "fileSystemConfiguration", - "typeMetadata").get1(); + "queryEntities").get1(); assertNotNull(cfgs); assertEquals(1, cfgs.size()); @@ -48,7 +49,8 @@ public class IgniteExcludeInConfigurationTest extends GridCommonAbstractTest { IgniteConfiguration cfg = cfgs.iterator().next(); assertEquals(1, cfg.getCacheConfiguration().length); - assertNull(cfg.getCacheConfiguration()[0].getTypeMetadata()); + + assertTrue(F.isEmpty(cfg.getCacheConfiguration()[0].getQueryEntities())); assertNull(cfg.getFileSystemConfiguration()); @@ -61,10 +63,10 @@ public class IgniteExcludeInConfigurationTest extends GridCommonAbstractTest { assertEquals(1, cfg.getCacheConfiguration().length); - Collection<CacheTypeMetadata> typeMetadatas = cfg.getCacheConfiguration()[0].getTypeMetadata(); + Collection<QueryEntity> queryEntities = cfg.getCacheConfiguration()[0].getQueryEntities(); - assertEquals(1, typeMetadatas.size()); - assertNull(typeMetadatas.iterator().next().getKeyType()); + assertEquals(1, queryEntities.size()); + assertNull(queryEntities.iterator().next().getKeyType()); } /** Spring should fail if bean class not exist in classpath. */ http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/spring/src/test/java/org/apache/ignite/spring/sprint-exclude.xml ---------------------------------------------------------------------- diff --git a/modules/spring/src/test/java/org/apache/ignite/spring/sprint-exclude.xml b/modules/spring/src/test/java/org/apache/ignite/spring/sprint-exclude.xml index 091b6ff..adc87a9 100644 --- a/modules/spring/src/test/java/org/apache/ignite/spring/sprint-exclude.xml +++ b/modules/spring/src/test/java/org/apache/ignite/spring/sprint-exclude.xml @@ -51,18 +51,29 @@ <list> <bean class="org.apache.ignite.configuration.CacheConfiguration"> <!-- Configure type metadata to enable queries. --> - <property name="typeMetadata"> + <property name="queryEntities"> <list> - <bean class="org.apache.ignite.cache.CacheTypeMetadata"> + <bean class="org.apache.ignite.cache.QueryEntity"> <property name="keyType" value="java.lang.Integer"/> <property name="valueType" value="Organization"/> - <property name="ascendingFields"> + <property name="fields"> <map> <entry key="name" value="java.lang.String"/> </map> </property> + <property name="indexes"> + <list> + <bean class="org.apache.ignite.cache.QueryIndex"> + <property name="fields"> + <map> + <entry key="name" value="true"/> + </map> + </property> + </bean> + </list> + </property> </bean> - <bean class="org.apache.ignite.cache.CacheTypeMetadata2"/> + <bean class="org.apache.ignite.cache.QueryEntity2"/> </list> </property> </bean> http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/web-console/web-agent/README.txt ---------------------------------------------------------------------- diff --git a/modules/web-console/web-agent/README.txt b/modules/web-console/web-agent/README.txt index 81df1cb..c915871 100644 --- a/modules/web-console/web-agent/README.txt +++ b/modules/web-console/web-agent/README.txt @@ -7,7 +7,7 @@ Two main functions of Ignite Web Agent: 1. Proxy between Ignite Web Console and Ignite Grid to execute SQL statements and collect metrics for monitoring. You may need to specify URI for connect to Ignite REST server via "-n" option. - 2. Proxy between Ignite Web Console and user RDBMS to collect database metadata for later CacheTypeMetadata configuration. + 2. Proxy between Ignite Web Console and user RDBMS to collect database metadata for later indexed types configuration. You may need to copy JDBC driver into "./jdbc-drivers" subfolder or specify path via "-d" option. Usage example: http://git-wip-us.apache.org/repos/asf/ignite/blob/1811ede4/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java index c85595d..437d309 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java @@ -49,7 +49,6 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheEntryEventSerializableFilter; import org.apache.ignite.cache.CacheMemoryMode; import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.CacheTypeMetadata; import org.apache.ignite.cache.QueryEntity; import org.apache.ignite.cache.QueryIndex; import org.apache.ignite.cache.affinity.Affinity; @@ -300,29 +299,29 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark } } - if (configuration.getTypeMetadata() != null) { - Collection<CacheTypeMetadata> entries = configuration.getTypeMetadata(); + if (configuration.getQueryEntities() != null) { + Collection<QueryEntity> entities = configuration.getQueryEntities(); - for (CacheTypeMetadata cacheTypeMetadata : entries) { + for (QueryEntity entity : entities) { try { - if (cacheTypeMetadata.getKeyType() != null) { - Class keyCls = Class.forName(cacheTypeMetadata.getKeyType()); + if (entity.getKeyType() != null) { + Class keyCls = Class.forName(entity.getKeyType()); if (ModelUtil.canCreateInstance(keyCls)) keys.add(keyCls); else throw new IgniteException("Class is unknown for the load test. Make sure you " + - "specified its full name [clsName=" + cacheTypeMetadata.getKeyType() + ']'); + "specified its full name [clsName=" + entity.getKeyType() + ']'); } - if (cacheTypeMetadata.getValueType() != null) { - Class valCls = Class.forName(cacheTypeMetadata.getValueType()); + if (entity.getValueType() != null) { + Class valCls = Class.forName(entity.getValueType()); if (ModelUtil.canCreateInstance(valCls)) values.add(valCls); else throw new IgniteException("Class is unknown for the load test. Make sure you " + - "specified its full name [clsName=" + cacheTypeMetadata.getKeyType() + ']'); + "specified its full name [clsName=" + entity.getKeyType() + ']'); } } catch (ClassNotFoundException e) { @@ -443,8 +442,7 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark */ private boolean isClassDefinedInConfig(CacheConfiguration configuration) { return (configuration.getIndexedTypes() != null && configuration.getIndexedTypes().length > 0) - || !CollectionUtils.isEmpty(configuration.getQueryEntities()) - || !CollectionUtils.isEmpty(configuration.getTypeMetadata()); + || !CollectionUtils.isEmpty(configuration.getQueryEntities()); } /** @@ -978,7 +976,8 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark } /** - * @return SQL string. + * @param sql Base SQL. + * @return Randomized SQL string. */ private String randomizeSql(String sql) { int cnt = StringUtils.countOccurrencesOf(sql, "%s");