Search in sources :

Example 11 with CacheExistsException

use of org.apache.geode.cache.CacheExistsException in project geode by apache.

the class ConcurrentIndexUpdateWithoutWLDUnitTest method getAvailableCacheElseCreateCache.

private final void getAvailableCacheElseCreateCache() {
    synchronized (ConcurrentIndexUpdateWithInplaceObjectModFalseDUnitTest.class) {
        try {
            Cache newCache = GemFireCacheImpl.getInstance();
            if (null == newCache) {
                System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE", "true");
                newCache = CacheFactory.create(getSystem());
            }
            PRQueryDUnitHelper.setCache(newCache);
        } catch (CacheExistsException e) {
            // TODO: remove error handling
            Assert.fail("the cache already exists", e);
        } catch (RuntimeException ex) {
            throw ex;
        } catch (Exception ex) {
            Assert.fail("Checked exception while initializing cache??", ex);
        } finally {
            System.clearProperty(DistributionConfig.GEMFIRE_PREFIX + "DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE");
        }
    }
}
Also used : CacheExistsException(org.apache.geode.cache.CacheExistsException) CacheExistsException(org.apache.geode.cache.CacheExistsException) CacheException(org.apache.geode.cache.CacheException) Cache(org.apache.geode.cache.Cache)

Aggregations

CacheExistsException (org.apache.geode.cache.CacheExistsException)11 CacheException (org.apache.geode.cache.CacheException)9 Connection (java.sql.Connection)4 SQLException (java.sql.SQLException)4 Context (javax.naming.Context)4 NamingException (javax.naming.NamingException)4 DataSource (javax.sql.DataSource)4 UserTransaction (javax.transaction.UserTransaction)4 Cache (org.apache.geode.cache.Cache)4 CacheLoaderException (org.apache.geode.cache.CacheLoaderException)4 JTAUtils (org.apache.geode.internal.jta.JTAUtils)4 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)4 Test (org.junit.Test)4 IOException (java.io.IOException)3 Statement (java.sql.Statement)3 RegionExistsException (org.apache.geode.cache.RegionExistsException)2 TimeoutException (org.apache.geode.cache.TimeoutException)2 InternalCache (org.apache.geode.internal.cache.InternalCache)2 IgnoredException (org.apache.geode.test.dunit.IgnoredException)2 File (java.io.File)1