Search in sources :

Example 1 with IndexType

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

the class OrderByPartitionedDUnitTest method createIndex.

private void createIndex(VM vm, final String indexName, IndexType indexType, final String indexedExpression, final String fromClause) {
    int indxTypeCode = -1;
    if (indexType.equals(IndexType.FUNCTIONAL)) {
        indxTypeCode = 0;
    } else if (indexType.equals(IndexType.PRIMARY_KEY)) {
        indxTypeCode = 1;
    } else if (indexType.equals(IndexType.HASH)) {
        indxTypeCode = 2;
    }
    final int finalIndxTypeCode = indxTypeCode;
    vm.invoke(new SerializableRunnable("create index") {

        public void run() {
            try {
                Cache cache = getCache();
                IndexType indxType = null;
                if (finalIndxTypeCode == 0) {
                    indxType = IndexType.FUNCTIONAL;
                } else if (finalIndxTypeCode == 1) {
                    indxType = IndexType.PRIMARY_KEY;
                } else if (finalIndxTypeCode == 2) {
                    indxType = IndexType.HASH;
                }
                cache.getQueryService().createIndex(indexName, indxType, indexedExpression, fromClause);
            } catch (RegionNotFoundException e) {
                fail(e.toString());
            } catch (IndexExistsException e) {
                fail(e.toString());
            } catch (IndexNameConflictException e) {
                fail(e.toString());
            }
        }
    });
}
Also used : IndexExistsException(org.apache.geode.cache.query.IndexExistsException) IndexNameConflictException(org.apache.geode.cache.query.IndexNameConflictException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) IndexType(org.apache.geode.cache.query.IndexType) Cache(org.apache.geode.cache.Cache)

Example 2 with IndexType

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

the class NonDistinctOrderByDUnitImpl method createIndex.

protected void createIndex(VM vm, final String indexName, IndexType indexType, final String indexedExpression, final String fromClause) {
    int indxTypeCode = -1;
    if (indexType.equals(IndexType.FUNCTIONAL)) {
        indxTypeCode = 0;
    } else if (indexType.equals(IndexType.PRIMARY_KEY)) {
        indxTypeCode = 1;
    } else if (indexType.equals(IndexType.HASH)) {
        indxTypeCode = 2;
    }
    final int finalIndxTypeCode = indxTypeCode;
    vm.invoke(new SerializableRunnable("create index") {

        public void run() {
            try {
                Cache cache = getCache();
                IndexType indxType = null;
                if (finalIndxTypeCode == 0) {
                    indxType = IndexType.FUNCTIONAL;
                } else if (finalIndxTypeCode == 1) {
                    indxType = IndexType.PRIMARY_KEY;
                } else if (finalIndxTypeCode == 2) {
                    indxType = IndexType.HASH;
                }
                cache.getQueryService().createIndex(indexName, indxType, indexedExpression, fromClause);
            } catch (RegionNotFoundException e) {
                fail(e.toString());
            } catch (IndexExistsException e) {
                fail(e.toString());
            } catch (IndexNameConflictException e) {
                fail(e.toString());
            }
        }
    });
}
Also used : IndexExistsException(org.apache.geode.cache.query.IndexExistsException) IndexNameConflictException(org.apache.geode.cache.query.IndexNameConflictException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) IndexType(org.apache.geode.cache.query.IndexType) Cache(org.apache.geode.cache.Cache)

Example 3 with IndexType

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

the class NonDistinctOrderByPartitionedDUnitTest method createTestInstance.

@Override
protected NonDistinctOrderByTestImplementation createTestInstance() {
    Host host = Host.getHost(0);
    final VM vm0 = host.getVM(0);
    final VM vm1 = host.getVM(1);
    final VM vm2 = host.getVM(2);
    final VM vm3 = host.getVM(3);
    NonDistinctOrderByTestImplementation test = new NonDistinctOrderByTestImplementation() {

        @Override
        public Region createRegion(String regionName, Class valueConstraint) {
            // TODO Auto-generated method stub
            Region rgn = createAccessor(regionName, valueConstraint);
            createPR(vm1, regionName, valueConstraint);
            createPR(vm2, regionName, valueConstraint);
            createPR(vm3, regionName, valueConstraint);
            return rgn;
        }

        @Override
        public Index createIndex(String indexName, String indexedExpression, String regionPath) throws IndexInvalidException, IndexNameConflictException, IndexExistsException, RegionNotFoundException, UnsupportedOperationException {
            Index indx = createIndexOnAccessor(indexName, indexedExpression, regionPath);
            /*
         * NonDistinctOrderByPartitionedDUnit.this.createIndex(vm1, indexName, indexedExpression,
         * regionPath); NonDistinctOrderByPartitionedDUnit.this.createIndex(vm2, indexName,
         * indexedExpression, regionPath); NonDistinctOrderByPartitionedDUnit.this.createIndex(vm3,
         * indexName, indexedExpression, regionPath);
         */
            return indx;
        }

        @Override
        public Index createIndex(String indexName, IndexType indexType, String indexedExpression, String fromClause) throws IndexInvalidException, IndexNameConflictException, IndexExistsException, RegionNotFoundException, UnsupportedOperationException {
            Index indx = createIndexOnAccessor(indexName, indexType, indexedExpression, fromClause);
            /*
         * NonDistinctOrderByPartitionedDUnit.this.createIndex(vm1, indexName, indexType,
         * indexedExpression, fromClause); NonDistinctOrderByPartitionedDUnit.this.createIndex(vm2,
         * indexName, indexType, indexedExpression, fromClause);
         * NonDistinctOrderByPartitionedDUnit.this.createIndex(vm3, indexName,
         * indexType,indexedExpression, fromClause);
         */
            return indx;
        }

        @Override
        public boolean assertIndexUsedOnQueryNode() {
            return false;
        }
    };
    return test;
}
Also used : NonDistinctOrderByTestImplementation(org.apache.geode.cache.query.functional.NonDistinctOrderByTestImplementation) VM(org.apache.geode.test.dunit.VM) Region(org.apache.geode.cache.Region) Host(org.apache.geode.test.dunit.Host) Index(org.apache.geode.cache.query.Index) IndexType(org.apache.geode.cache.query.IndexType)

Example 4 with IndexType

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

the class OrderByPartitionedDUnitTest method createTestInstance.

private OrderByPartitionedJUnitTest createTestInstance() {
    Host host = Host.getHost(0);
    final VM vm0 = host.getVM(0);
    final VM vm1 = host.getVM(1);
    final VM vm2 = host.getVM(2);
    final VM vm3 = host.getVM(3);
    OrderByPartitionedJUnitTest test = new OrderByPartitionedJUnitTest() {

        @Override
        public Region createRegion(String regionName, Class valueConstraint) {
            // TODO Auto-generated method stub
            Region rgn = createAccessor(regionName, valueConstraint);
            createPR(vm1, regionName, valueConstraint);
            createPR(vm2, regionName, valueConstraint);
            createPR(vm3, regionName, valueConstraint);
            return rgn;
        }

        @Override
        public Index createIndex(String indexName, String indexedExpression, String regionPath) throws IndexInvalidException, IndexNameConflictException, IndexExistsException, RegionNotFoundException, UnsupportedOperationException {
            Index indx = createIndexOnAccessor(indexName, indexedExpression, regionPath);
            return indx;
        }

        @Override
        public Index createIndex(String indexName, IndexType indexType, String indexedExpression, String fromClause) throws IndexInvalidException, IndexNameConflictException, IndexExistsException, RegionNotFoundException, UnsupportedOperationException {
            Index indx = createIndexOnAccessor(indexName, indexType, indexedExpression, fromClause);
            return indx;
        }

        @Override
        public boolean assertIndexUsedOnQueryNode() {
            return false;
        }
    };
    return test;
}
Also used : OrderByPartitionedJUnitTest(org.apache.geode.cache.query.functional.OrderByPartitionedJUnitTest) VM(org.apache.geode.test.dunit.VM) Region(org.apache.geode.cache.Region) Host(org.apache.geode.test.dunit.Host) Index(org.apache.geode.cache.query.Index) IndexType(org.apache.geode.cache.query.IndexType)

Aggregations

IndexType (org.apache.geode.cache.query.IndexType)4 Cache (org.apache.geode.cache.Cache)2 Region (org.apache.geode.cache.Region)2 Index (org.apache.geode.cache.query.Index)2 IndexExistsException (org.apache.geode.cache.query.IndexExistsException)2 IndexNameConflictException (org.apache.geode.cache.query.IndexNameConflictException)2 RegionNotFoundException (org.apache.geode.cache.query.RegionNotFoundException)2 Host (org.apache.geode.test.dunit.Host)2 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)2 VM (org.apache.geode.test.dunit.VM)2 NonDistinctOrderByTestImplementation (org.apache.geode.cache.query.functional.NonDistinctOrderByTestImplementation)1 OrderByPartitionedJUnitTest (org.apache.geode.cache.query.functional.OrderByPartitionedJUnitTest)1