Search in sources :

Example 16 with IndexNameConflictException

use of org.apache.geode.cache.query.IndexNameConflictException in project geode by apache.

the class PRQueryDUnitHelper method getCacheSerializableRunnableForDuplicatePRIndexCreate.

/**
   * This function creates a duplicate index should throw an IndexNameConflictException and if not
   * the test should fail.
   */
public CacheSerializableRunnable getCacheSerializableRunnableForDuplicatePRIndexCreate(final String prRegionName, final String indexName, final String indexedExpression, final String fromClause, final String alias) {
    SerializableRunnable prIndexCreator = new CacheSerializableRunnable("DuplicatePartitionedIndexCreator") {

        @Override
        public void run2() {
            Cache cache = getCache();
            LogWriter logger = cache.getLogger();
            QueryService qs = cache.getQueryService();
            Region region = cache.getRegion(prRegionName);
            try {
                if (null != fromClause) {
                    qs.createIndex(indexName, IndexType.FUNCTIONAL, indexedExpression, fromClause);
                    throw new RuntimeException("Should throw an exception because " + "the index with name : " + indexName + " should already exists");
                } else {
                    qs.createIndex(indexName, IndexType.FUNCTIONAL, indexedExpression, region.getFullPath() + " " + alias);
                    throw new RuntimeException("Should throw an exception because " + "the index with name : " + indexName + " should already exists");
                }
            } catch (IndexExistsException e) {
                logger.info("Index Exists Excetpiont righteously throw ", e);
            } catch (IndexNameConflictException ex) {
                logger.info("Gott the right exception");
            } catch (RegionNotFoundException exx) {
                // TODO Auto-generated catch block
                Assert.fail("Region Not found in this vm ", exx);
            }
        }
    };
    return (CacheSerializableRunnable) prIndexCreator;
}
Also used : IndexExistsException(org.apache.geode.cache.query.IndexExistsException) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) LogWriter(org.apache.geode.LogWriter) QueryService(org.apache.geode.cache.query.QueryService) IndexNameConflictException(org.apache.geode.cache.query.IndexNameConflictException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) Cache(org.apache.geode.cache.Cache)

Aggregations

IndexNameConflictException (org.apache.geode.cache.query.IndexNameConflictException)16 IndexExistsException (org.apache.geode.cache.query.IndexExistsException)15 Cache (org.apache.geode.cache.Cache)9 Index (org.apache.geode.cache.query.Index)9 QueryService (org.apache.geode.cache.query.QueryService)8 Region (org.apache.geode.cache.Region)7 RegionNotFoundException (org.apache.geode.cache.query.RegionNotFoundException)6 Test (org.junit.Test)6 Query (org.apache.geode.cache.query.Query)5 QueryException (org.apache.geode.cache.query.QueryException)5 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)5 CacheException (org.apache.geode.cache.CacheException)4 SelectResults (org.apache.geode.cache.query.SelectResults)4 Portfolio (org.apache.geode.cache.query.data.Portfolio)4 StructSetOrResultsSet (org.apache.geode.cache.query.functional.StructSetOrResultsSet)4 Host (org.apache.geode.test.dunit.Host)4 VM (org.apache.geode.test.dunit.VM)4 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)4 IndexInvalidException (org.apache.geode.cache.query.IndexInvalidException)3 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)3