Repository: ignite Updated Branches: refs/heads/ignite-9893 [created] d9bd387e3
http://git-wip-us.apache.org/repos/asf/ignite/blob/d9bd387e/modules/hibernate-5.3/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/hibernate-5.3/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java b/modules/hibernate-5.3/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java new file mode 100644 index 0000000..8b75bb7 --- /dev/null +++ b/modules/hibernate-5.3/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java @@ -0,0 +1,118 @@ +/* + * 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.cache.store.hibernate; + +import java.io.File; +import java.net.URL; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.testframework.junits.cache.GridAbstractCacheStoreSelfTest; +import org.hibernate.FlushMode; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.resource.transaction.spi.TransactionStatus; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Cache store test. + */ +@RunWith(JUnit4.class) +public class CacheHibernateBlobStoreSelfTest extends + GridAbstractCacheStoreSelfTest<CacheHibernateBlobStore<Object, Object>> { + /** + * @throws Exception If failed. + */ + public CacheHibernateBlobStoreSelfTest() throws Exception { + // No-op. + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + Session s = store.session(null); + + if (s == null) + return; + + try { + s.createQuery("delete from " + CacheHibernateBlobStoreEntry.class.getSimpleName()) + .setFlushMode(FlushMode.ALWAYS).executeUpdate(); + + Transaction hTx = s.getTransaction(); + + if (hTx != null && hTx.getStatus() == TransactionStatus.ACTIVE) + hTx.commit(); + } + finally { + s.close(); + } + } + + /** {@inheritDoc} */ + @Override protected CacheHibernateBlobStore<Object, Object> store() { + return new CacheHibernateBlobStore<>(); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testConfigurationByUrl() throws Exception { + URL url = U.resolveIgniteUrl(CacheHibernateStoreFactorySelfTest.MODULE_PATH + + "/src/test/resources/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml"); + + assert url != null; + + store.setHibernateConfigurationPath(url.toString()); + + // Store will be implicitly initialized. + store.load("key"); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testConfigurationByFile() throws Exception { + URL url = U.resolveIgniteUrl(CacheHibernateStoreFactorySelfTest.MODULE_PATH + + "/src/test/resources/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml"); + + assert url != null; + + File file = new File(url.toURI()); + + store.setHibernateConfigurationPath(file.getAbsolutePath()); + + // Store will be implicitly initialized. + store.load("key"); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testConfigurationByResource() throws Exception { + store.setHibernateConfigurationPath("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml"); + + // Store will be implicitly initialized. + store.load("key"); + } + +} http://git-wip-us.apache.org/repos/asf/ignite/blob/d9bd387e/modules/hibernate-5.3/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/hibernate-5.3/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java b/modules/hibernate-5.3/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java new file mode 100644 index 0000000..0a9a881 --- /dev/null +++ b/modules/hibernate-5.3/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java @@ -0,0 +1,336 @@ +/* + * 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.cache.store.hibernate; + +import java.sql.Connection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Callable; +import javax.naming.NamingException; +import javax.naming.Reference; +import javax.persistence.EntityGraph; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceUnitUtil; +import javax.persistence.Query; +import javax.persistence.SynchronizationType; +import javax.persistence.criteria.CriteriaBuilder; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteException; +import org.apache.ignite.Ignition; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.hibernate.Cache; +import org.hibernate.HibernateException; +import org.hibernate.Metamodel; +import org.hibernate.Session; +import org.hibernate.SessionBuilder; +import org.hibernate.SessionFactory; +import org.hibernate.StatelessSession; +import org.hibernate.StatelessSessionBuilder; +import org.hibernate.TypeHelper; +import org.hibernate.boot.spi.SessionFactoryOptions; +import org.hibernate.engine.spi.FilterDefinition; +import org.hibernate.metadata.ClassMetadata; +import org.hibernate.metadata.CollectionMetadata; +import org.hibernate.stat.Statistics; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Test for Cache jdbc blob store factory. + */ +@RunWith(JUnit4.class) +public class CacheHibernateStoreFactorySelfTest extends GridCommonAbstractTest { + /** Cache name. */ + private static final String CACHE_NAME = "test"; + + /** */ + static final String MODULE_PATH = "modules/hibernate-5.3/"; + + /** + * @throws Exception If failed. + */ + @Test + public void testCacheConfiguration() throws Exception { + try (Ignite ignite1 = startGrid(0)) { + IgniteCache<Integer, String> cache1 = ignite1.getOrCreateCache(cacheConfiguration()); + + checkStore(cache1); + } + } + + /** + * @throws Exception If failed. + */ + @Test + public void testXmlConfiguration() throws Exception { + try (Ignite ignite = Ignition.start(MODULE_PATH + "/src/test/config/factory-cache.xml")) { + try(Ignite ignite1 = Ignition.start(MODULE_PATH + "/src/test/config/factory-cache1.xml")) { + checkStore(ignite.<Integer, String>cache(CACHE_NAME), DummySessionFactoryExt.class); + + checkStore(ignite1.<Integer, String>cache(CACHE_NAME), DummySessionFactory.class); + } + } + } + + + /** + * @throws Exception If failed. + */ + @Test + public void testIncorrectBeanConfiguration() { + GridTestUtils.assertThrows(log, new Callable<Object>() { + @Override + public Object call() throws Exception { + String path = MODULE_PATH + "/src/test/config/factory-incorrect-store-cache.xml"; + try (Ignite ignite = Ignition.start(path)) { + ignite.cache(CACHE_NAME).getConfiguration(CacheConfiguration.class).getCacheStoreFactory().create(); + } + return null; + } + }, IgniteException.class, "Failed to load bean in application context"); + } + + /** + * @return Cache configuration with store. + */ + private CacheConfiguration<Integer, String> cacheConfiguration() { + CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); + + CacheHibernateBlobStoreFactory<Integer, String> factory = new CacheHibernateBlobStoreFactory(); + + factory.setHibernateConfigurationPath("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml"); + + cfg.setCacheStoreFactory(factory); + + return cfg; + } + + /** + * @param cache Ignite cache. + * @param dataSrcClass Data source class. + * @throws Exception If store parameters is not the same as in configuration xml. + */ + private void checkStore(IgniteCache<Integer, String> cache, Class<?> dataSrcClass) throws Exception { + CacheHibernateBlobStore store = (CacheHibernateBlobStore)cache + .getConfiguration(CacheConfiguration.class).getCacheStoreFactory().create(); + + assertEquals(dataSrcClass, + GridTestUtils.getFieldValue(store, CacheHibernateBlobStore.class, "sesFactory").getClass()); + } + + /** + * @param cache Ignite cache. + * @throws Exception If store parameters is not the same as in configuration xml. + */ + private void checkStore(IgniteCache<Integer, String> cache) throws Exception { + CacheHibernateBlobStore store = (CacheHibernateBlobStore)cache.getConfiguration(CacheConfiguration.class) + .getCacheStoreFactory().create(); + + assertEquals("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml", + GridTestUtils.getFieldValue(store, CacheHibernateBlobStore.class, "hibernateCfgPath")); + } + + /** + * + */ + public static class DummySessionFactoryExt extends DummySessionFactory { + /** */ + public DummySessionFactoryExt() { + // No-op. + } + } + + /** + * + */ + public static class DummySessionFactory implements SessionFactory { + /** {@inheritDoc} */ + @Override public SessionFactoryOptions getSessionFactoryOptions() { + return null; + } + + /** {@inheritDoc} */ + @Override public SessionBuilder withOptions() { + return null; + } + + /** {@inheritDoc} */ + @Override public Session openSession() throws HibernateException { + return null; + } + + /** {@inheritDoc} */ + @Override public Session getCurrentSession() throws HibernateException { + return null; + } + + /** {@inheritDoc} */ + @Override public StatelessSessionBuilder withStatelessOptions() { + return null; + } + + /** {@inheritDoc} */ + @Override public StatelessSession openStatelessSession() { + return null; + } + + /** {@inheritDoc} */ + @Override public StatelessSession openStatelessSession(Connection conn) { + return null; + } + + /** {@inheritDoc} */ + @Override public ClassMetadata getClassMetadata(Class entityCls) { + return null; + } + + /** {@inheritDoc} */ + @Override public ClassMetadata getClassMetadata(String entityName) { + return null; + } + + /** {@inheritDoc} */ + @Override public CollectionMetadata getCollectionMetadata(String roleName) { + return null; + } + + /** {@inheritDoc} */ + @Override public Map<String, ClassMetadata> getAllClassMetadata() { + return null; + } + + /** {@inheritDoc} */ + @Override public Map getAllCollectionMetadata() { + return null; + } + + /** {@inheritDoc} */ + @Override public Statistics getStatistics() { + return null; + } + + /** {@inheritDoc} */ + @Override public void close() throws HibernateException { + } + + @Override + public Map<String, Object> getProperties() { + return null; + } + + /** {@inheritDoc} */ + @Override public boolean isClosed() { + return false; + } + + /** {@inheritDoc} */ + @Override public Cache getCache() { + return null; + } + + @Override + public PersistenceUnitUtil getPersistenceUnitUtil() { + return null; + } + + @Override + public void addNamedQuery(String name, Query query) { + + } + + @Override + public <T> T unwrap(Class<T> cls) { + return null; + } + + @Override + public <T> void addNamedEntityGraph(String graphName, EntityGraph<T> entityGraph) { + + } + + /** {@inheritDoc} */ + @Override public Set getDefinedFilterNames() { + return null; + } + + /** {@inheritDoc} */ + @Override public FilterDefinition getFilterDefinition(String filterName) throws HibernateException { + return null; + } + + /** {@inheritDoc} */ + @Override public boolean containsFetchProfileDefinition(String name) { + return false; + } + + /** {@inheritDoc} */ + @Override public TypeHelper getTypeHelper() { + return null; + } + + /** {@inheritDoc} */ + @Override public Reference getReference() throws NamingException { + return null; + } + + @Override + public <T> List<EntityGraph<? super T>> findEntityGraphsByType(Class<T> aClass) { + return null; + } + + @Override + public EntityManager createEntityManager() { + return null; + } + + @Override + public EntityManager createEntityManager(Map map) { + return null; + } + + @Override + public EntityManager createEntityManager(SynchronizationType synchronizationType) { + return null; + } + + @Override + public EntityManager createEntityManager(SynchronizationType synchronizationType, Map map) { + return null; + } + + @Override + public CriteriaBuilder getCriteriaBuilder() { + return null; + } + + @Override + public Metamodel getMetamodel() { + return null; + } + + @Override + public boolean isOpen() { + return false; + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/d9bd387e/modules/hibernate-5.3/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/hibernate-5.3/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java b/modules/hibernate-5.3/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java new file mode 100644 index 0000000..0010425 --- /dev/null +++ b/modules/hibernate-5.3/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java @@ -0,0 +1,242 @@ +/* + * 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.cache.store.hibernate; + +import java.io.Serializable; +import java.util.Map; +import javax.cache.Cache; +import javax.cache.configuration.Factory; +import javax.cache.integration.CacheLoaderException; +import javax.cache.integration.CacheWriterException; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import org.apache.ignite.cache.store.CacheStore; +import org.apache.ignite.cache.store.CacheStoreAdapter; +import org.apache.ignite.cache.store.CacheStoreSession; +import org.apache.ignite.cache.store.CacheStoreSessionListener; +import org.apache.ignite.cache.store.CacheStoreSessionListenerAbstractSelfTest; +import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener; +import org.apache.ignite.lang.IgniteBiInClosure; +import org.apache.ignite.resources.CacheStoreSessionResource; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.hibernate.cfg.Configuration; +import org.hibernate.resource.transaction.spi.TransactionStatus; + +/** + * Tests for {@link CacheJdbcStoreSessionListener}. + */ +public class CacheHibernateStoreSessionListenerSelfTest extends CacheStoreSessionListenerAbstractSelfTest { + /** {@inheritDoc} */ + @Override protected Factory<? extends CacheStore<Integer, Integer>> storeFactory() { + return new Factory<CacheStore<Integer, Integer>>() { + @Override public CacheStore<Integer, Integer> create() { + return new Store(); + } + }; + } + + /** {@inheritDoc} */ + @Override protected Factory<CacheStoreSessionListener> sessionListenerFactory() { + return new Factory<CacheStoreSessionListener>() { + @Override public CacheStoreSessionListener create() { + CacheHibernateStoreSessionListener lsnr = new CacheHibernateStoreSessionListener(); + + SessionFactory sesFactory = new Configuration(). + setProperty("hibernate.connection.url", URL). + addAnnotatedClass(Table1.class). + addAnnotatedClass(Table2.class). + buildSessionFactory(); + + lsnr.setSessionFactory(sesFactory); + + return lsnr; + } + }; + } + + /** + */ + private static class Store extends CacheStoreAdapter<Integer, Integer> { + /** */ + private static String SES_CONN_KEY = "ses_conn"; + + /** */ + @CacheStoreSessionResource + private CacheStoreSession ses; + + /** {@inheritDoc} */ + @Override public void loadCache(IgniteBiInClosure<Integer, Integer> clo, Object... args) { + loadCacheCnt.incrementAndGet(); + + checkSession(); + } + + /** {@inheritDoc} */ + @Override public Integer load(Integer key) throws CacheLoaderException { + loadCnt.incrementAndGet(); + + checkSession(); + + return null; + } + + /** {@inheritDoc} */ + @Override public void write(Cache.Entry<? extends Integer, ? extends Integer> entry) + throws CacheWriterException { + writeCnt.incrementAndGet(); + + checkSession(); + + if (write.get()) { + Session hibSes = ses.attachment(); + + switch (ses.cacheName()) { + case "cache1": + hibSes.save(new Table1(entry.getKey(), entry.getValue())); + + break; + + case "cache2": + if (fail.get()) + throw new CacheWriterException("Expected failure."); + + hibSes.save(new Table2(entry.getKey(), entry.getValue())); + + break; + + default: + throw new CacheWriterException("Wring cache: " + ses.cacheName()); + } + } + } + + /** {@inheritDoc} */ + @Override public void delete(Object key) throws CacheWriterException { + deleteCnt.incrementAndGet(); + + checkSession(); + } + + /** {@inheritDoc} */ + @Override public void sessionEnd(boolean commit) { + assertNull(ses.attachment()); + } + + /** + */ + private void checkSession() { + Session hibSes = ses.attachment(); + + assertNotNull(hibSes); + + assertTrue(hibSes.isOpen()); + + Transaction tx = hibSes.getTransaction(); + + assertNotNull(tx); + + if (ses.isWithinTransaction()) + assertEquals(TransactionStatus.ACTIVE, tx.getStatus()); + else + assertFalse("Unexpected status: " + tx.getStatus(), tx.getStatus() == TransactionStatus.ACTIVE); + + verifySameInstance(hibSes); + } + + /** + * @param hibSes Session. + */ + private void verifySameInstance(Session hibSes) { + Map<String, Session> props = ses.properties(); + + Session sesConn = props.get(SES_CONN_KEY); + + if (sesConn == null) + props.put(SES_CONN_KEY, hibSes); + else { + assertSame(hibSes, sesConn); + + reuseCnt.incrementAndGet(); + } + } + } + + /** + */ + @Entity + @Table(name = "Table1") + private static class Table1 implements Serializable { + /** */ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Integer id; + + /** */ + @Column(name = "key") + private int key; + + /** */ + @Column(name = "value") + private int value; + + /** + * @param key Key. + * @param value Value. + */ + private Table1(int key, int value) { + this.key = key; + this.value = value; + } + } + + /** + */ + @Entity + @Table(name = "Table2") + private static class Table2 implements Serializable { + /** */ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Integer id; + + /** */ + @Column(name = "key") + private int key; + + /** */ + @Column(name = "value") + private int value; + + /** + * @param key Key. + * @param value Value. + */ + private Table2(int key, int value) { + this.key = key; + this.value = value; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/d9bd387e/modules/hibernate-5.3/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java ---------------------------------------------------------------------- diff --git a/modules/hibernate-5.3/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java b/modules/hibernate-5.3/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java new file mode 100644 index 0000000..8af9886 --- /dev/null +++ b/modules/hibernate-5.3/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java @@ -0,0 +1,22 @@ +/* + * 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 description. --> + * Contains internal tests or test related classes and interfaces. + */ +package org.apache.ignite.cache.store.hibernate; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/d9bd387e/modules/hibernate-5.3/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate53TestSuite.java ---------------------------------------------------------------------- diff --git a/modules/hibernate-5.3/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate53TestSuite.java b/modules/hibernate-5.3/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate53TestSuite.java new file mode 100644 index 0000000..51842a8 --- /dev/null +++ b/modules/hibernate-5.3/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate53TestSuite.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.testsuites; + +import junit.framework.TestSuite; +import org.apache.ignite.internal.binary.BinaryMarshaller; +import org.apache.ignite.testframework.config.GridTestProperties; + +/** + * + */ +public class IgniteBinaryHibernate53TestSuite extends TestSuite { + /** + * @return Test suite. + * @throws Exception If failed. + */ + public static TestSuite suite() throws Exception { + GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName()); + + return IgniteHibernate53TestSuite.suite(); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/d9bd387e/modules/hibernate-5.3/src/test/java/org/apache/ignite/testsuites/IgniteHibernate53TestSuite.java ---------------------------------------------------------------------- diff --git a/modules/hibernate-5.3/src/test/java/org/apache/ignite/testsuites/IgniteHibernate53TestSuite.java b/modules/hibernate-5.3/src/test/java/org/apache/ignite/testsuites/IgniteHibernate53TestSuite.java new file mode 100644 index 0000000..794cffe --- /dev/null +++ b/modules/hibernate-5.3/src/test/java/org/apache/ignite/testsuites/IgniteHibernate53TestSuite.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.testsuites; + +import junit.framework.JUnit4TestAdapter; +import junit.framework.TestSuite; +import org.apache.ignite.cache.hibernate.HibernateL2CacheConfigurationSelfTest; +import org.apache.ignite.cache.hibernate.HibernateL2CacheMultiJvmTest; +import org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest; +import org.apache.ignite.cache.hibernate.HibernateL2CacheStrategySelfTest; +import org.apache.ignite.cache.hibernate.HibernateL2CacheTransactionalSelfTest; +import org.apache.ignite.cache.hibernate.HibernateL2CacheTransactionalUseSyncSelfTest; +import org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreNodeRestartTest; +import org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreSelfTest; +import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreFactorySelfTest; +import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreSessionListenerSelfTest; + +/** + * Hibernate integration tests. + */ +public class IgniteHibernate53TestSuite extends TestSuite { + /** + * @return Test suite. + */ + public static TestSuite suite() { + TestSuite suite = new TestSuite("Hibernate5 Integration Test Suite"); + + // Hibernate L2 cache. + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheTransactionalSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheTransactionalUseSyncSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheConfigurationSelfTest.class)); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheStrategySelfTest.class)); + suite.addTest(new JUnit4TestAdapter(HibernateL2CacheMultiJvmTest.class)); + + suite.addTest(new JUnit4TestAdapter(CacheHibernateBlobStoreSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(CacheHibernateBlobStoreNodeRestartTest.class)); + + suite.addTest(new JUnit4TestAdapter(CacheHibernateStoreSessionListenerSelfTest.class)); + + suite.addTest(new JUnit4TestAdapter(CacheHibernateStoreFactorySelfTest.class)); + + return suite; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/d9bd387e/modules/hibernate-5.3/src/test/resources/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml ---------------------------------------------------------------------- diff --git a/modules/hibernate-5.3/src/test/resources/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml b/modules/hibernate-5.3/src/test/resources/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml new file mode 100644 index 0000000..6240599 --- /dev/null +++ b/modules/hibernate-5.3/src/test/resources/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml @@ -0,0 +1,41 @@ +<?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. +--> + + +<!DOCTYPE hibernate-configuration PUBLIC + "-//Hibernate/Hibernate Configuration DTD 3.0//EN" + "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> + +<hibernate-configuration> + <session-factory> + <!-- Show SQL. --> + <property name="show_sql">true</property> + + <!-- Database connection settings (private in-memory database). --> + <property name="connection.url">jdbc:h2:mem:example;DB_CLOSE_DELAY=-1</property> + + <!-- Only validate the database schema on startup in production mode. --> + <property name="hbm2ddl.auto">update</property> + + <!-- H2 dialect. --> + <property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property> + + <!-- Mappings. --> + <mapping resource="org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml"/> + </session-factory> +</hibernate-configuration> http://git-wip-us.apache.org/repos/asf/ignite/blob/d9bd387e/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyFactory.java ---------------------------------------------------------------------- diff --git a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyFactory.java b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyFactory.java index 0226c1c..c48d482 100644 --- a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyFactory.java +++ b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyFactory.java @@ -19,8 +19,9 @@ package org.apache.ignite.cache.hibernate; import java.util.HashMap; import java.util.Map; -import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; @@ -54,9 +55,6 @@ public class HibernateAccessStrategyFactory { /** Hibernate L2 cache Ignite instance name property name. */ public static final String IGNITE_INSTANCE_NAME_PROPERTY = "org.apache.ignite.hibernate.ignite_instance_name"; - /** Default cache property name. */ - public static final String DFLT_CACHE_NAME_PROPERTY = "org.apache.ignite.hibernate.default_cache"; - /** Property prefix used to specify region name to cache name mapping. */ public static final String REGION_CACHE_PROPERTY = "org.apache.ignite.hibernate.region_cache."; @@ -66,13 +64,16 @@ public class HibernateAccessStrategyFactory { /** */ public static final String GRID_CONFIG_PROPERTY = "org.apache.ignite.hibernate.grid_config"; + /** Disable atomicity check when caches are created lazily. */ + public static final String VERIFY_ATOMICITY = "org.apache.ignite.hibernate.verify_atomicity"; + + /** When set, all cache names in ignite will be fetched using the specified prefix. */ + public static final String CACHE_PREFIX = "org.apache.ignite.hibernate.cache_prefix"; + /** Grid providing caches. */ private Ignite ignite; - /** Default cache. */ - private HibernateCacheProxy dfltCache; - - /** Region name to cache name mapping. */ + /** Region name to cache name (without prefix) mapping. */ private final Map<String, String> regionCaches = new HashMap<>(); /** */ @@ -81,6 +82,12 @@ public class HibernateAccessStrategyFactory { /** */ private final ConcurrentHashMap<String, ThreadLocal> threadLocMap = new ConcurrentHashMap<>(); + /** */ + private String cachePrefix; + + /** */ + private boolean verifyAtomicity = true; + /** * @param keyTransformer Key transformer. * @param eConverter Exception converter. @@ -91,53 +98,45 @@ public class HibernateAccessStrategyFactory { } /** - * @param props Properties. + * @param cfgValues {@link Map} of config values. */ - public void start(Properties props) { - String gridCfg = props.getProperty(GRID_CONFIG_PROPERTY); - String igniteInstanceName = props.getProperty(IGNITE_INSTANCE_NAME_PROPERTY); + public void start(Map<Object, Object> cfgValues) { + cachePrefix = cfgValues.getOrDefault(CACHE_PREFIX, "").toString(); + + verifyAtomicity = Boolean.valueOf(cfgValues.getOrDefault(VERIFY_ATOMICITY, verifyAtomicity).toString()); - if (igniteInstanceName == null) - igniteInstanceName = props.getProperty(GRID_NAME_PROPERTY); + Object gridCfg = cfgValues.get(GRID_CONFIG_PROPERTY); + + Object igniteInstanceName = cfgValues.get(IGNITE_INSTANCE_NAME_PROPERTY); if (gridCfg != null) { try { - ignite = G.start(gridCfg); + ignite = G.start(gridCfg.toString()); } catch (IgniteException e) { throw eConverter.convert(e); } } else - ignite = Ignition.ignite(igniteInstanceName); + ignite = Ignition.ignite(igniteInstanceName == null ? null : igniteInstanceName.toString()); - for (Map.Entry<Object, Object> prop : props.entrySet()) { - String key = prop.getKey().toString(); + for (Map.Entry entry : cfgValues.entrySet()) { + String key = entry.getKey().toString(); if (key.startsWith(REGION_CACHE_PROPERTY)) { String regionName = key.substring(REGION_CACHE_PROPERTY.length()); - String cacheName = prop.getValue().toString(); + String cacheName = entry.getValue().toString(); - if (((IgniteKernal)ignite).getCache(cacheName) == null) + if (((IgniteKernal) ignite).getCache(cachePrefix + cacheName) == null) { throw new IllegalArgumentException("Cache '" + cacheName + "' specified for region '" + regionName + "' " + "is not configured."); + } regionCaches.put(regionName, cacheName); } } - String dfltCacheName = props.getProperty(DFLT_CACHE_NAME_PROPERTY); - - if (dfltCacheName != null) { - IgniteInternalCache<Object, Object> dfltCache = ((IgniteKernal)ignite).getCache(dfltCacheName); - - if (dfltCache == null) - throw new IllegalArgumentException("Cache specified as default is not configured: " + dfltCacheName); - - this.dfltCache = new HibernateCacheProxy(dfltCache, keyTransformer); - } - IgniteLogger log = ignite.log().getLogger(getClass()); if (log.isDebugEnabled()) @@ -158,19 +157,48 @@ public class HibernateAccessStrategyFactory { HibernateCacheProxy regionCache(String regionName) { String cacheName = regionCaches.get(regionName); - if (cacheName == null) { - if (dfltCache != null) - return dfltCache; - + if (cacheName == null) cacheName = regionName; + + cacheName = cachePrefix + cacheName; + + Supplier<IgniteInternalCache<Object, Object>> lazyCache = new LazyCacheSupplier(cacheName, regionName); + + return new HibernateCacheProxy(cacheName, lazyCache, keyTransformer); + } + + /** */ + private class LazyCacheSupplier implements Supplier<IgniteInternalCache<Object, Object>> { + /** */ + private final AtomicReference<IgniteInternalCache<Object, Object>> reference = new AtomicReference<>(); + + /** */ + private final String cacheName; + + /** */ + private final String regionName; + + /** */ + private LazyCacheSupplier(String cacheName, String regionName) { + this.cacheName = cacheName; + this.regionName = regionName; } - IgniteInternalCache<Object, Object> cache = ((IgniteKernal)ignite).getCache(cacheName); + /** {@inheritDoc} */ + @Override public IgniteInternalCache<Object, Object> get() { + IgniteInternalCache<Object, Object> cache = reference.get(); - if (cache == null) - throw new IllegalArgumentException("Cache '" + cacheName + "' for region '" + regionName + "' is not configured."); + if (cache == null) { + cache = ((IgniteKernal)ignite).getCache(cacheName); - return new HibernateCacheProxy(cache, keyTransformer); + if (cache == null) + throw new IllegalArgumentException("Cache '" + cacheName + "' for region '" + regionName + "' is not configured."); + + reference.compareAndSet(null, cache); + } + + return cache; + } } /** @@ -203,9 +231,12 @@ public class HibernateAccessStrategyFactory { * @return Access strategy implementation. */ HibernateAccessStrategyAdapter createReadWriteStrategy(HibernateCacheProxy cache) { - if (cache.configuration().getAtomicityMode() != TRANSACTIONAL) - throw new IllegalArgumentException("Hibernate READ-WRITE access strategy must have Ignite cache with " + - "'TRANSACTIONAL' atomicity mode: " + cache.name()); + if (verifyAtomicity) { + if (cache.configuration().getAtomicityMode() != TRANSACTIONAL) { + throw new IllegalArgumentException("Hibernate READ-WRITE access strategy must have Ignite cache with " + + "'TRANSACTIONAL' atomicity mode: " + cache.name()); + } + } return new HibernateReadWriteAccessStrategy(ignite, cache, threadLoc, eConverter); } @@ -215,19 +246,22 @@ public class HibernateAccessStrategyFactory { * @return Access strategy implementation. */ HibernateAccessStrategyAdapter createTransactionalStrategy(HibernateCacheProxy cache) { - if (cache.configuration().getAtomicityMode() != TRANSACTIONAL) - throw new IllegalArgumentException("Hibernate TRANSACTIONAL access strategy must have Ignite cache with " + - "'TRANSACTIONAL' atomicity mode: " + cache.name()); - - TransactionConfiguration txCfg = ignite.configuration().getTransactionConfiguration(); - - if (txCfg == null || - (txCfg.getTxManagerFactory() == null - && txCfg.getTxManagerLookupClassName() == null - && cache.configuration().getTransactionManagerLookupClassName() == null)) { - throw new IllegalArgumentException("Hibernate TRANSACTIONAL access strategy must have Ignite with " + - "Factory<TransactionManager> configured (see IgniteConfiguration." + - "getTransactionConfiguration().setTxManagerFactory()): " + cache.name()); + if (verifyAtomicity) { + if (cache.configuration().getAtomicityMode() != TRANSACTIONAL) { + throw new IllegalArgumentException("Hibernate TRANSACTIONAL access strategy must have Ignite cache with " + + "'TRANSACTIONAL' atomicity mode: " + cache.name()); + } + + TransactionConfiguration txCfg = ignite.configuration().getTransactionConfiguration(); + + if (txCfg == null || + (txCfg.getTxManagerFactory() == null + && txCfg.getTxManagerLookupClassName() == null + && cache.configuration().getTransactionManagerLookupClassName() == null)) { + throw new IllegalArgumentException("Hibernate TRANSACTIONAL access strategy must have Ignite with " + + "Factory<TransactionManager> configured (see IgniteConfiguration." + + "getTransactionConfiguration().setTxManagerFactory()): " + cache.name()); + } } return new HibernateTransactionalAccessStrategy(ignite, cache, eConverter); http://git-wip-us.apache.org/repos/asf/ignite/blob/d9bd387e/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java ---------------------------------------------------------------------- diff --git a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java index 1752313..f53a14c 100644 --- a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java +++ b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java @@ -24,6 +24,7 @@ import java.util.LinkedList; import java.util.Map; import java.util.Set; import java.util.UUID; +import java.util.function.Supplier; import javax.cache.Cache; import javax.cache.expiry.ExpiryPolicy; import javax.cache.processor.EntryProcessor; @@ -51,23 +52,30 @@ import org.jetbrains.annotations.Nullable; * Hibernate cache proxy used to substitute hibernate keys with ignite keys. */ public class HibernateCacheProxy implements IgniteInternalCache<Object, Object> { - /** Delegate. */ - private final IgniteInternalCache<Object, Object> delegate; + /** Delegate is lazily loaded which allows for creation of caches after the SPI is bootstrapped */ + private final Supplier<IgniteInternalCache<Object, Object>> delegate; /** Transformer. */ private final HibernateKeyTransformer keyTransformer; + /** */ + private String cacheName; + /** + * @param cacheName Cache name. Should match delegate.get().name(). Needed for lazy loading. * @param delegate Delegate. * @param keyTransformer Key keyTransformer. */ HibernateCacheProxy( - IgniteInternalCache<Object, Object> delegate, + String cacheName, + Supplier<IgniteInternalCache<Object, Object>> delegate, HibernateKeyTransformer keyTransformer ) { + assert cacheName != null; assert delegate != null; assert keyTransformer != null; + this.cacheName = cacheName; this.delegate = delegate; this.keyTransformer = keyTransformer; } @@ -81,42 +89,42 @@ public class HibernateCacheProxy implements IgniteInternalCache<Object, Object> /** {@inheritDoc} */ @Override public String name() { - return delegate.name(); + return cacheName; } /** {@inheritDoc} */ @Override public boolean skipStore() { - return delegate.skipStore(); + return delegate.get().skipStore(); } /** {@inheritDoc} */ @Override public IgniteInternalCache setSkipStore(boolean skipStore) { - return delegate.setSkipStore(skipStore); + return delegate.get().setSkipStore(skipStore); } /** {@inheritDoc} */ @Override public boolean isEmpty() { - return delegate.isEmpty(); + return delegate.get().isEmpty(); } /** {@inheritDoc} */ @Override public boolean containsKey(Object key) { - return delegate.containsKey(keyTransformer.transform(key)); + return delegate.get().containsKey(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Boolean> containsKeyAsync(Object key) { - return delegate.containsKeyAsync(keyTransformer.transform(key)); + return delegate.get().containsKeyAsync(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Override public boolean containsKeys(Collection keys) { - return delegate.containsKey(transform(keys)); + return delegate.get().containsKey(transform(keys)); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Boolean> containsKeysAsync(Collection keys) { - return delegate.containsKeysAsync(transform(keys)); + return delegate.get().containsKeysAsync(transform(keys)); } /** {@inheritDoc} */ @@ -124,147 +132,147 @@ public class HibernateCacheProxy implements IgniteInternalCache<Object, Object> Object key, CachePeekMode[] peekModes ) throws IgniteCheckedException { - return delegate.localPeek(keyTransformer.transform(key), peekModes); + return delegate.get().localPeek(keyTransformer.transform(key), peekModes); } /** {@inheritDoc} */ @Override public Iterable<Cache.Entry<Object, Object>> localEntries( CachePeekMode[] peekModes ) throws IgniteCheckedException { - return delegate.localEntries(peekModes); + return delegate.get().localEntries(peekModes); } /** {@inheritDoc} */ @Nullable @Override public Object get(Object key) throws IgniteCheckedException { - return delegate.get(keyTransformer.transform(key)); + return delegate.get().get(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Nullable @Override public CacheEntry getEntry(Object key) throws IgniteCheckedException { - return delegate.getEntry(keyTransformer.transform(key)); + return delegate.get().getEntry(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Override public IgniteInternalFuture getAsync(Object key) { - return delegate.getAsync(keyTransformer.transform(key)); + return delegate.get().getAsync(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<CacheEntry<Object, Object>> getEntryAsync(Object key) { - return delegate.getEntryAsync(keyTransformer.transform(key)); + return delegate.get().getEntryAsync(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Override public Map getAll(@Nullable Collection keys) throws IgniteCheckedException { - return delegate.getAll(transform(keys)); + return delegate.get().getAll(transform(keys)); } /** {@inheritDoc} */ @Override public Collection<CacheEntry<Object, Object>> getEntries( @Nullable Collection keys) throws IgniteCheckedException { - return delegate.getEntries(transform(keys)); + return delegate.get().getEntries(transform(keys)); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Map<Object, Object>> getAllAsync(@Nullable Collection keys) { - return delegate.getAllAsync(transform(keys)); + return delegate.get().getAllAsync(transform(keys)); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Collection<CacheEntry<Object,Object>>> getEntriesAsync( @Nullable Collection keys ) { - return delegate.getEntriesAsync(transform(keys)); + return delegate.get().getEntriesAsync(transform(keys)); } /** {@inheritDoc} */ @Nullable @Override public Object getAndPut(Object key, Object val) throws IgniteCheckedException { - return delegate.getAndPut(keyTransformer.transform(key), val); + return delegate.get().getAndPut(keyTransformer.transform(key), val); } /** {@inheritDoc} */ @Override public IgniteInternalFuture getAndPutAsync(Object key, Object val) { - return delegate.getAndPutAsync(keyTransformer.transform(key), val); + return delegate.get().getAndPutAsync(keyTransformer.transform(key), val); } /** {@inheritDoc} */ @Override public boolean put(Object key, Object val) throws IgniteCheckedException { - return delegate.put(keyTransformer.transform(key), val); + return delegate.get().put(keyTransformer.transform(key), val); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Boolean> putAsync(Object key, Object val) { - return delegate.putAsync(keyTransformer.transform(key), val); + return delegate.get().putAsync(keyTransformer.transform(key), val); } /** {@inheritDoc} */ @Nullable @Override public Object getAndPutIfAbsent(Object key, Object val) throws IgniteCheckedException { - return delegate.getAndPutIfAbsent(keyTransformer.transform(key), val); + return delegate.get().getAndPutIfAbsent(keyTransformer.transform(key), val); } /** {@inheritDoc} */ @Override public IgniteInternalFuture getAndPutIfAbsentAsync(Object key, Object val) { - return delegate.getAndPutIfAbsentAsync(keyTransformer.transform(key), val); + return delegate.get().getAndPutIfAbsentAsync(keyTransformer.transform(key), val); } /** {@inheritDoc} */ @Override public boolean putIfAbsent(Object key, Object val) throws IgniteCheckedException { - return delegate.putIfAbsent(keyTransformer.transform(key), val); + return delegate.get().putIfAbsent(keyTransformer.transform(key), val); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Boolean> putIfAbsentAsync(Object key, Object val) { - return delegate.putIfAbsentAsync(keyTransformer.transform(key), val); + return delegate.get().putIfAbsentAsync(keyTransformer.transform(key), val); } /** {@inheritDoc} */ @Nullable @Override public Object getAndReplace(Object key, Object val) throws IgniteCheckedException { - return delegate.getAndReplace(keyTransformer.transform(key), val); + return delegate.get().getAndReplace(keyTransformer.transform(key), val); } /** {@inheritDoc} */ @Override public IgniteInternalFuture getAndReplaceAsync(Object key, Object val) { - return delegate.getAndReplaceAsync(keyTransformer.transform(key), val); + return delegate.get().getAndReplaceAsync(keyTransformer.transform(key), val); } /** {@inheritDoc} */ @Override public boolean replace(Object key, Object val) throws IgniteCheckedException { - return delegate.replace(keyTransformer.transform(key), val); + return delegate.get().replace(keyTransformer.transform(key), val); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Boolean> replaceAsync(Object key, Object val) { - return delegate.replaceAsync(keyTransformer.transform(key), val); + return delegate.get().replaceAsync(keyTransformer.transform(key), val); } /** {@inheritDoc} */ @Override public boolean replace(Object key, Object oldVal, Object newVal) throws IgniteCheckedException { - return delegate.replace(keyTransformer.transform(key), oldVal, newVal); + return delegate.get().replace(keyTransformer.transform(key), oldVal, newVal); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Boolean> replaceAsync(Object key, Object oldVal, Object newVal) { - return delegate.replaceAsync(keyTransformer.transform(key), oldVal, newVal); + return delegate.get().replaceAsync(keyTransformer.transform(key), oldVal, newVal); } /** {@inheritDoc} */ @Override public void putAll(@Nullable Map m) throws IgniteCheckedException { - delegate.putAll(transform(m)); + delegate.get().putAll(transform(m)); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<?> putAllAsync(@Nullable Map m) { - return delegate.putAllAsync(transform(m)); + return delegate.get().putAllAsync(transform(m)); } /** {@inheritDoc} */ @Override public Set keySet() { - return delegate.keySet(); + return delegate.get().keySet(); } /** {@inheritDoc} */ @Override public Set<Cache.Entry<Object, Object>> entrySet() { - return delegate.entrySet(); + return delegate.get().entrySet(); } /** {@inheritDoc} */ @@ -272,7 +280,7 @@ public class HibernateCacheProxy implements IgniteInternalCache<Object, Object> TransactionConcurrency concurrency, TransactionIsolation isolation ) { - return delegate.txStart(concurrency, isolation); + return delegate.get().txStart(concurrency, isolation); } /** {@inheritDoc} */ @@ -280,7 +288,7 @@ public class HibernateCacheProxy implements IgniteInternalCache<Object, Object> TransactionConcurrency concurrency, TransactionIsolation isolation ) { - return delegate.txStartEx(concurrency, isolation); + return delegate.get().txStartEx(concurrency, isolation); } /** {@inheritDoc} */ @@ -290,337 +298,337 @@ public class HibernateCacheProxy implements IgniteInternalCache<Object, Object> long timeout, int txSize ) { - return delegate.txStart(concurrency, isolation, timeout, txSize); + return delegate.get().txStart(concurrency, isolation, timeout, txSize); } /** {@inheritDoc} */ @Nullable @Override public GridNearTxLocal tx() { - return delegate.tx(); + return delegate.get().tx(); } /** {@inheritDoc} */ @Override public boolean evict(Object key) { - return delegate.evict(keyTransformer.transform(key)); + return delegate.get().evict(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Override public void evictAll(@Nullable Collection keys) { - delegate.evictAll(transform(keys)); + delegate.get().evictAll(transform(keys)); } /** {@inheritDoc} */ @Override public void clearLocally(boolean srv, boolean near, boolean readers) { - delegate.clearLocally(srv, near, readers); + delegate.get().clearLocally(srv, near, readers); } /** {@inheritDoc} */ @Override public boolean clearLocally(Object key) { - return delegate.clearLocally(keyTransformer.transform(key)); + return delegate.get().clearLocally(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Override public void clearLocallyAll(Set keys, boolean srv, boolean near, boolean readers) { - delegate.clearLocallyAll((Set<?>)transform(keys), srv, near, readers); + delegate.get().clearLocallyAll((Set<?>)transform(keys), srv, near, readers); } /** {@inheritDoc} */ @Override public void clear(Object key) throws IgniteCheckedException { - delegate.clear(keyTransformer.transform(key)); + delegate.get().clear(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Override public void clearAll(Set keys) throws IgniteCheckedException { - delegate.clearAll((Set<?>)transform(keys)); + delegate.get().clearAll((Set<?>)transform(keys)); } /** {@inheritDoc} */ @Override public void clear() throws IgniteCheckedException { - delegate.clear(); + delegate.get().clear(); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<?> clearAsync() { - return delegate.clearAsync(); + return delegate.get().clearAsync(); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<?> clearAsync(Object key) { - return delegate.clearAsync(keyTransformer.transform(key)); + return delegate.get().clearAsync(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<?> clearAllAsync(Set keys) { - return delegate.clearAllAsync((Set<?>)transform(keys)); + return delegate.get().clearAllAsync((Set<?>)transform(keys)); } /** {@inheritDoc} */ @Nullable @Override public Object getAndRemove(Object key) throws IgniteCheckedException { - return delegate.getAndRemove(keyTransformer.transform(key)); + return delegate.get().getAndRemove(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Override public IgniteInternalFuture getAndRemoveAsync(Object key) { - return delegate.getAndRemoveAsync(keyTransformer.transform(key)); + return delegate.get().getAndRemoveAsync(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Override public boolean remove(Object key) throws IgniteCheckedException { - return delegate.remove(keyTransformer.transform(key)); + return delegate.get().remove(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Boolean> removeAsync(Object key) { - return delegate.removeAsync(keyTransformer.transform(key)); + return delegate.get().removeAsync(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Override public boolean remove(Object key, Object val) throws IgniteCheckedException { - return delegate.remove(keyTransformer.transform(key), val); + return delegate.get().remove(keyTransformer.transform(key), val); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Boolean> removeAsync(Object key, Object val) { - return delegate.removeAsync(keyTransformer.transform(key), val); + return delegate.get().removeAsync(keyTransformer.transform(key), val); } /** {@inheritDoc} */ @Override public void removeAll(@Nullable Collection keys) throws IgniteCheckedException { - delegate.removeAll(transform(keys)); + delegate.get().removeAll(transform(keys)); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<?> removeAllAsync(@Nullable Collection keys) { - return delegate.removeAllAsync(transform(keys)); + return delegate.get().removeAllAsync(transform(keys)); } /** {@inheritDoc} */ @Override public void removeAll() throws IgniteCheckedException { - delegate.removeAll(); + delegate.get().removeAll(); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<?> removeAllAsync() { - return delegate.removeAllAsync(); + return delegate.get().removeAllAsync(); } /** {@inheritDoc} */ @Override public boolean lock(Object key, long timeout) throws IgniteCheckedException { - return delegate.lock(keyTransformer.transform(key), timeout); + return delegate.get().lock(keyTransformer.transform(key), timeout); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Boolean> lockAsync(Object key, long timeout) { - return delegate.lockAsync(keyTransformer.transform(key), timeout); + return delegate.get().lockAsync(keyTransformer.transform(key), timeout); } /** {@inheritDoc} */ @Override public boolean lockAll(@Nullable Collection keys, long timeout) throws IgniteCheckedException { - return delegate.lockAll(transform(keys), timeout); + return delegate.get().lockAll(transform(keys), timeout); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Boolean> lockAllAsync(@Nullable Collection keys, long timeout) { - return delegate.lockAllAsync(transform(keys), timeout); + return delegate.get().lockAllAsync(transform(keys), timeout); } /** {@inheritDoc} */ @Override public void unlock(Object key) throws IgniteCheckedException { - delegate.unlock(keyTransformer.transform(key)); + delegate.get().unlock(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Override public void unlockAll(@Nullable Collection keys) throws IgniteCheckedException { - delegate.unlockAll(transform(keys)); + delegate.get().unlockAll(transform(keys)); } /** {@inheritDoc} */ @Override public boolean isLocked(Object key) { - return delegate.isLocked(keyTransformer.transform(key)); + return delegate.get().isLocked(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Override public boolean isLockedByThread(Object key) { - return delegate.isLockedByThread(keyTransformer.transform(key)); + return delegate.get().isLockedByThread(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Override public int size() { - return delegate.size(); + return delegate.get().size(); } /** {@inheritDoc} */ @Override public long sizeLong() { - return delegate.sizeLong(); + return delegate.get().sizeLong(); } /** {@inheritDoc} */ @Override public int localSize(CachePeekMode[] peekModes) throws IgniteCheckedException { - return delegate.localSize(peekModes); + return delegate.get().localSize(peekModes); } /** {@inheritDoc} */ @Override public long localSizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException { - return delegate.localSizeLong(peekModes); + return delegate.get().localSizeLong(peekModes); } /** {@inheritDoc} */ @Override public long localSizeLong(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException { - return delegate.localSizeLong(partition, peekModes); + return delegate.get().localSizeLong(partition, peekModes); } /** {@inheritDoc} */ @Override public int size(CachePeekMode[] peekModes) throws IgniteCheckedException { - return delegate.size(peekModes); + return delegate.get().size(peekModes); } /** {@inheritDoc} */ @Override public long sizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException { - return delegate.sizeLong(peekModes); + return delegate.get().sizeLong(peekModes); } /** {@inheritDoc} */ @Override public long sizeLong(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException { - return delegate.sizeLong(partition, peekModes); + return delegate.get().sizeLong(partition, peekModes); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Integer> sizeAsync(CachePeekMode[] peekModes) { - return delegate.sizeAsync(peekModes); + return delegate.get().sizeAsync(peekModes); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Long> sizeLongAsync(CachePeekMode[] peekModes) { - return delegate.sizeLongAsync(peekModes); + return delegate.get().sizeLongAsync(peekModes); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Long> sizeLongAsync(int partition, CachePeekMode[] peekModes) { - return delegate.sizeLongAsync(partition, peekModes); + return delegate.get().sizeLongAsync(partition, peekModes); } /** {@inheritDoc} */ @Override public int nearSize() { - return delegate.nearSize(); + return delegate.get().nearSize(); } /** {@inheritDoc} */ @Override public int primarySize() { - return delegate.primarySize(); + return delegate.get().primarySize(); } /** {@inheritDoc} */ @Override public long primarySizeLong() { - return delegate.primarySizeLong(); + return delegate.get().primarySizeLong(); } /** {@inheritDoc} */ @Override public CacheConfiguration configuration() { - return delegate.configuration(); + return delegate.get().configuration(); } /** {@inheritDoc} */ @Override public Affinity affinity() { - return delegate.affinity(); + return delegate.get().affinity(); } /** {@inheritDoc} */ @Override public CacheMetrics clusterMetrics() { - return delegate.clusterMetrics(); + return delegate.get().clusterMetrics(); } /** {@inheritDoc} */ @Override public CacheMetrics clusterMetrics(ClusterGroup grp) { - return delegate.clusterMetrics(grp); + return delegate.get().clusterMetrics(grp); } /** {@inheritDoc} */ @Override public CacheMetrics localMetrics() { - return delegate.localMetrics(); + return delegate.get().localMetrics(); } /** {@inheritDoc} */ @Override public CacheMetricsMXBean clusterMxBean() { - return delegate.clusterMxBean(); + return delegate.get().clusterMxBean(); } /** {@inheritDoc} */ @Override public CacheMetricsMXBean localMxBean() { - return delegate.localMxBean(); + return delegate.get().localMxBean(); } /** {@inheritDoc} */ @Override public long offHeapEntriesCount() { - return delegate.offHeapEntriesCount(); + return delegate.get().offHeapEntriesCount(); } /** {@inheritDoc} */ @Override public long offHeapAllocatedSize() { - return delegate.offHeapAllocatedSize(); + return delegate.get().offHeapAllocatedSize(); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<?> rebalance() { - return delegate.rebalance(); + return delegate.get().rebalance(); } /** {@inheritDoc} */ @Override public IgniteInternalCache forSubjectId(UUID subjId) { - return delegate.forSubjectId(subjId); + return delegate.get().forSubjectId(subjId); } /** {@inheritDoc} */ @Nullable @Override public Object getForcePrimary(Object key) throws IgniteCheckedException { - return delegate.getForcePrimary(keyTransformer.transform(key)); + return delegate.get().getForcePrimary(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Override public IgniteInternalFuture getForcePrimaryAsync(Object key) { - return delegate.getForcePrimaryAsync(keyTransformer.transform(key)); + return delegate.get().getForcePrimaryAsync(keyTransformer.transform(key)); } /** {@inheritDoc} */ @Override public Map getAllOutTx(Set keys) throws IgniteCheckedException { - return delegate.getAllOutTx((Set<?>)transform(keys)); + return delegate.get().getAllOutTx((Set<?>)transform(keys)); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Map<Object, Object>> getAllOutTxAsync(Set keys) { - return delegate.getAllOutTxAsync((Set<?>)transform(keys)); + return delegate.get().getAllOutTxAsync((Set<?>)transform(keys)); } /** {@inheritDoc} */ @Override public boolean isIgfsDataCache() { - return delegate.isIgfsDataCache(); + return delegate.get().isIgfsDataCache(); } /** {@inheritDoc} */ @Override public long igfsDataSpaceUsed() { - return delegate.igfsDataSpaceUsed(); + return delegate.get().igfsDataSpaceUsed(); } /** {@inheritDoc} */ @Nullable @Override public ExpiryPolicy expiry() { - return delegate.expiry(); + return delegate.get().expiry(); } /** {@inheritDoc} */ @Override public IgniteInternalCache withExpiryPolicy(ExpiryPolicy plc) { - return delegate.withExpiryPolicy(plc); + return delegate.get().withExpiryPolicy(plc); } /** {@inheritDoc} */ @Override public IgniteInternalCache withNoRetries() { - return delegate.withNoRetries(); + return delegate.get().withNoRetries(); } /** {@inheritDoc} */ @Override public <K1, V1> IgniteInternalCache<K1, V1> withAllowAtomicOpsInTx() { - return delegate.withAllowAtomicOpsInTx(); + return delegate.get().withAllowAtomicOpsInTx(); } /** {@inheritDoc} */ @Override public GridCacheContext context() { - return delegate.context(); + return delegate.get().context(); } /** {@inheritDoc} */ @@ -628,7 +636,7 @@ public class HibernateCacheProxy implements IgniteInternalCache<Object, Object> @Nullable IgniteBiPredicate p, @Nullable Object... args ) throws IgniteCheckedException { - delegate.localLoadCache(p, args); + delegate.get().localLoadCache(p, args); } /** {@inheritDoc} */ @@ -636,27 +644,27 @@ public class HibernateCacheProxy implements IgniteInternalCache<Object, Object> @Nullable IgniteBiPredicate p, @Nullable Object... args ) { - return delegate.localLoadCacheAsync(p, args); + return delegate.get().localLoadCacheAsync(p, args); } /** {@inheritDoc} */ @Override public Collection<Integer> lostPartitions() { - return delegate.lostPartitions(); + return delegate.get().lostPartitions(); } /** {@inheritDoc} */ @Override public void preloadPartition(int part) throws IgniteCheckedException { - delegate.preloadPartition(part); + delegate.get().preloadPartition(part); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<?> preloadPartitionAsync(int part) throws IgniteCheckedException { - return delegate.preloadPartitionAsync(part); + return delegate.get().preloadPartitionAsync(part); } /** {@inheritDoc} */ @Override public boolean localPreloadPartition(int part) throws IgniteCheckedException { - return delegate.localPreloadPartition(part); + return delegate.get().localPreloadPartition(part); } /** {@inheritDoc} */ @@ -666,27 +674,27 @@ public class HibernateCacheProxy implements IgniteInternalCache<Object, Object> EntryProcessor entryProcessor, Object... args ) throws IgniteCheckedException { - return delegate.invoke(topVer, key, entryProcessor, args); + return delegate.get().invoke(topVer, key, entryProcessor, args); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Map> invokeAllAsync(Map map, Object... args) { - return delegate.invokeAllAsync(map, args); + return delegate.get().invokeAllAsync(map, args); } /** {@inheritDoc} */ @Override public Map invokeAll(Map map, Object... args) throws IgniteCheckedException { - return delegate.invokeAll(map, args); + return delegate.get().invokeAll(map, args); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<Map> invokeAllAsync(Set keys, EntryProcessor entryProcessor, Object... args) { - return delegate.invokeAllAsync((Set<?>)transform(keys), entryProcessor, args); + return delegate.get().invokeAllAsync((Set<?>)transform(keys), entryProcessor, args); } /** {@inheritDoc} */ @Override public Map invokeAll(Set keys, EntryProcessor entryProcessor, Object... args) throws IgniteCheckedException { - return delegate.invokeAll((Set<?>)transform(keys), entryProcessor, args); + return delegate.get().invokeAll((Set<?>)transform(keys), entryProcessor, args); } /** {@inheritDoc} */ @@ -695,7 +703,7 @@ public class HibernateCacheProxy implements IgniteInternalCache<Object, Object> EntryProcessor entryProcessor, Object... args ) { - return delegate.invokeAsync(keyTransformer.transform(key), entryProcessor, args); + return delegate.get().invokeAsync(keyTransformer.transform(key), entryProcessor, args); } /** {@inheritDoc} */ @@ -704,7 +712,7 @@ public class HibernateCacheProxy implements IgniteInternalCache<Object, Object> EntryProcessor entryProcessor, Object... args ) throws IgniteCheckedException { - return delegate.invoke(keyTransformer.transform(key), entryProcessor, args); + return delegate.get().invoke(keyTransformer.transform(key), entryProcessor, args); } /** {@inheritDoc} */ @@ -712,42 +720,42 @@ public class HibernateCacheProxy implements IgniteInternalCache<Object, Object> boolean keepBinary, @Nullable IgniteBiPredicate p ) throws IgniteCheckedException { - return delegate.scanIterator(keepBinary, p); + return delegate.get().scanIterator(keepBinary, p); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<?> removeAllConflictAsync(Map drMap) throws IgniteCheckedException { - return delegate.removeAllConflictAsync(drMap); + return delegate.get().removeAllConflictAsync(drMap); } /** {@inheritDoc} */ @Override public void removeAllConflict(Map drMap) throws IgniteCheckedException { - delegate.removeAllConflictAsync(drMap); + delegate.get().removeAllConflictAsync(drMap); } /** {@inheritDoc} */ @Override public IgniteInternalFuture<?> putAllConflictAsync(Map drMap) throws IgniteCheckedException { - return delegate.putAllConflictAsync(drMap); + return delegate.get().putAllConflictAsync(drMap); } /** {@inheritDoc} */ @Override public void putAllConflict(Map drMap) throws IgniteCheckedException { - delegate.putAllConflict(drMap); + delegate.get().putAllConflict(drMap); } /** {@inheritDoc} */ @Override public IgniteInternalCache keepBinary() { - return delegate.keepBinary(); + return delegate.get().keepBinary(); } /** {@inheritDoc} */ @Override public IgniteInternalCache cache() { - return delegate.cache(); + return delegate.get().cache(); } /** {@inheritDoc} */ @Override public Iterator iterator() { - return delegate.iterator(); + return delegate.get().iterator(); } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/d9bd387e/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 2bcdf16..fc71761 100644 --- a/pom.xml +++ b/pom.xml @@ -108,6 +108,7 @@ <module>modules/geospatial</module> <module>modules/hibernate-4.2</module> <module>modules/hibernate-5.1</module> + <module>modules/hibernate-5.3</module> <module>modules/schedule</module> <module>modules/web-console/web-agent</module> <module>modules/yardstick</module> @@ -245,6 +246,7 @@ <modules> <module>modules/hibernate-4.2</module> <module>modules/hibernate-5.1</module> + <module>modules/hibernate-5.3</module> <module>modules/geospatial</module> <module>modules/schedule</module> </modules>
