Search in sources :

Example 46 with SerializableRunnableIF

use of org.apache.geode.test.dunit.SerializableRunnableIF in project geode by apache.

the class PaginationDUnitTest method partitionedRegionStorageExceptionWhenAllDataStoreAreClosedWhilePagination.

@Test
@Parameters(method = "getListOfRegionTestTypes")
public void partitionedRegionStorageExceptionWhenAllDataStoreAreClosedWhilePagination(RegionTestableType regionTestType) {
    SerializableRunnableIF createIndex = () -> {
        LuceneService luceneService = LuceneServiceProvider.get(getCache());
        luceneService.createIndexFactory().setFields("text").create(INDEX_NAME, REGION_NAME);
    };
    dataStore1.invoke(() -> initDataStore(createIndex, regionTestType));
    accessor.invoke(() -> initAccessor(createIndex, regionTestType));
    putEntryInEachBucket();
    assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, FLUSH_WAIT_TIME_MS));
    accessor.invoke(() -> {
        Cache cache = getCache();
        LuceneService service = LuceneServiceProvider.get(cache);
        LuceneQuery<Integer, TestObject> query;
        query = service.createLuceneQueryFactory().setLimit(1000).setPageSize(PAGE_SIZE).create(INDEX_NAME, REGION_NAME, "world", "text");
        PageableLuceneQueryResults<Integer, TestObject> pages = query.findPages();
        assertTrue(pages.hasNext());
        List<LuceneResultStruct<Integer, TestObject>> page = pages.next();
        assertEquals(page.size(), PAGE_SIZE, page.size());
        dataStore1.invoke(() -> closeCache());
        try {
            page = pages.next();
            fail();
        } catch (Exception e) {
            Assert.assertEquals("Expected Exception = PartitionedRegionStorageException but hit " + e.toString(), true, e instanceof PartitionedRegionStorageException);
        }
    });
}
Also used : PartitionedRegionStorageException(org.apache.geode.cache.PartitionedRegionStorageException) SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) PartitionedRegionStorageException(org.apache.geode.cache.PartitionedRegionStorageException) Cache(org.apache.geode.cache.Cache) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 47 with SerializableRunnableIF

use of org.apache.geode.test.dunit.SerializableRunnableIF in project geode by apache.

the class RebalanceDUnitTest method putEntriesAndValidateQueryResults.

protected void putEntriesAndValidateQueryResults(RegionTestableType regionTestType) {
    SerializableRunnableIF createIndex = () -> {
        LuceneService luceneService = LuceneServiceProvider.get(getCache());
        luceneService.createIndexFactory().setFields("text").create(INDEX_NAME, REGION_NAME);
    };
    dataStore1.invoke(() -> initDataStore(createIndex, regionTestType));
    accessor.invoke(() -> initAccessor(createIndex, regionTestType));
    dataStore1.invoke(() -> LuceneTestUtilities.pauseSender(getCache()));
    putEntryInEachBucket();
    dataStore2.invoke(() -> initDataStore(createIndex, regionTestType));
    dataStore1.invoke(() -> LuceneTestUtilities.resumeSender(getCache()));
    assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, 60000));
    // dataStore3.invoke(() -> initDataStore(create, regionType));
    executeTextSearch(accessor, "world", "text", NUM_BUCKETS);
}
Also used : SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF)

Example 48 with SerializableRunnableIF

use of org.apache.geode.test.dunit.SerializableRunnableIF in project geode by apache.

the class PartitionedRegionQueryDUnitTest method tesRangeIndexDoesNotDeserializePdxObjects.

@Test
public void tesRangeIndexDoesNotDeserializePdxObjects() {
    SerializableRunnableIF createIndex = () -> {
        Cache cache = getCache();
        cache.getQueryService().createIndex("ContractDocumentIndex", "ref", "/region r, r.references ref");
    };
    String queryString = "select r.assetId,r.document from /region r, r.references ref where ref='B_2' limit 1000";
    PdxAssetFactory value = i -> new PdxNotDeserializableAsset(i, Integer.toString(i));
    createIndexDoesNotDerializePdxObjects(createIndex, queryString, value);
}
Also used : SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Arrays(java.util.Arrays) FunctionDomainException(org.apache.geode.cache.query.FunctionDomainException) DUnitEnv(org.apache.geode.test.dunit.DUnitEnv) JSONFormatter(org.apache.geode.pdx.JSONFormatter) Assert(org.apache.geode.test.dunit.Assert) NameResolutionException(org.apache.geode.cache.query.NameResolutionException) Cache(org.apache.geode.cache.Cache) RebalanceResults(org.apache.geode.cache.control.RebalanceResults) DistributionMessage(org.apache.geode.distributed.internal.DistributionMessage) CacheServer(org.apache.geode.cache.server.CacheServer) DefaultQuery(org.apache.geode.cache.query.internal.DefaultQuery) CancellationException(java.util.concurrent.CancellationException) DistributionMessageObserver(org.apache.geode.distributed.internal.DistributionMessageObserver) Collection(java.util.Collection) DataSerializable(org.apache.geode.DataSerializable) ClientRegionShortcut(org.apache.geode.cache.client.ClientRegionShortcut) Category(org.junit.experimental.categories.Category) Serializable(java.io.Serializable) IndexManager(org.apache.geode.cache.query.internal.index.IndexManager) List(java.util.List) DataInput(java.io.DataInput) ClientCache(org.apache.geode.cache.client.ClientCache) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) RebalanceOperation(org.apache.geode.cache.control.RebalanceOperation) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) IntStream(java.util.stream.IntStream) Struct(org.apache.geode.cache.query.Struct) Index(org.apache.geode.cache.query.Index) Query(org.apache.geode.cache.query.Query) DistributionManager(org.apache.geode.distributed.internal.DistributionManager) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) HashMap(java.util.HashMap) Host(org.apache.geode.test.dunit.Host) VM(org.apache.geode.test.dunit.VM) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) PdxWriter(org.apache.geode.pdx.PdxWriter) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LogWriterUtils(org.apache.geode.test.dunit.LogWriterUtils) QueryMessage(org.apache.geode.internal.cache.partitioned.QueryMessage) PdxSerializable(org.apache.geode.pdx.PdxSerializable) Region(org.apache.geode.cache.Region) NetworkUtils(org.apache.geode.test.dunit.NetworkUtils) DataOutput(java.io.DataOutput) Iterator(java.util.Iterator) AbstractIndex(org.apache.geode.cache.query.internal.index.AbstractIndex) AvailablePortHelper(org.apache.geode.internal.AvailablePortHelper) RegionShortcut(org.apache.geode.cache.RegionShortcut) Test(org.junit.Test) IOException(java.io.IOException) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) QueryService(org.apache.geode.cache.query.QueryService) CacheException(org.apache.geode.cache.CacheException) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory) PartitionedIndex(org.apache.geode.cache.query.internal.index.PartitionedIndex) SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) SelectResults(org.apache.geode.cache.query.SelectResults) JUnit4CacheTestCase(org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase) PdxReader(org.apache.geode.pdx.PdxReader) IndexNameConflictException(org.apache.geode.cache.query.IndexNameConflictException) TypeMismatchException(org.apache.geode.cache.query.TypeMismatchException) Assert(org.junit.Assert) IndexExistsException(org.apache.geode.cache.query.IndexExistsException) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) Cache(org.apache.geode.cache.Cache) ClientCache(org.apache.geode.cache.client.ClientCache) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) Test(org.junit.Test)

Example 49 with SerializableRunnableIF

use of org.apache.geode.test.dunit.SerializableRunnableIF in project geode by apache.

the class PartitionedRegionQueryDUnitTest method tesRangeIndexWithPdxObjects.

@Test
public void tesRangeIndexWithPdxObjects() {
    SerializableRunnableIF createIndex = () -> {
        Cache cache = getCache();
        cache.getQueryService().createIndex("ContractDocumentIndex", "ref", "/region r, r.references ref");
    };
    String queryString = "select r from /region r, r.references ref where ref='B_2' limit 1000";
    PdxAssetFactory value = i -> new PdxAsset(i, Integer.toString(i));
    createIndexDoesNotDerializePdxObjects(createIndex, queryString, value);
}
Also used : SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Arrays(java.util.Arrays) FunctionDomainException(org.apache.geode.cache.query.FunctionDomainException) DUnitEnv(org.apache.geode.test.dunit.DUnitEnv) JSONFormatter(org.apache.geode.pdx.JSONFormatter) Assert(org.apache.geode.test.dunit.Assert) NameResolutionException(org.apache.geode.cache.query.NameResolutionException) Cache(org.apache.geode.cache.Cache) RebalanceResults(org.apache.geode.cache.control.RebalanceResults) DistributionMessage(org.apache.geode.distributed.internal.DistributionMessage) CacheServer(org.apache.geode.cache.server.CacheServer) DefaultQuery(org.apache.geode.cache.query.internal.DefaultQuery) CancellationException(java.util.concurrent.CancellationException) DistributionMessageObserver(org.apache.geode.distributed.internal.DistributionMessageObserver) Collection(java.util.Collection) DataSerializable(org.apache.geode.DataSerializable) ClientRegionShortcut(org.apache.geode.cache.client.ClientRegionShortcut) Category(org.junit.experimental.categories.Category) Serializable(java.io.Serializable) IndexManager(org.apache.geode.cache.query.internal.index.IndexManager) List(java.util.List) DataInput(java.io.DataInput) ClientCache(org.apache.geode.cache.client.ClientCache) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) RebalanceOperation(org.apache.geode.cache.control.RebalanceOperation) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) IntStream(java.util.stream.IntStream) Struct(org.apache.geode.cache.query.Struct) Index(org.apache.geode.cache.query.Index) Query(org.apache.geode.cache.query.Query) DistributionManager(org.apache.geode.distributed.internal.DistributionManager) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) HashMap(java.util.HashMap) Host(org.apache.geode.test.dunit.Host) VM(org.apache.geode.test.dunit.VM) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) PdxWriter(org.apache.geode.pdx.PdxWriter) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LogWriterUtils(org.apache.geode.test.dunit.LogWriterUtils) QueryMessage(org.apache.geode.internal.cache.partitioned.QueryMessage) PdxSerializable(org.apache.geode.pdx.PdxSerializable) Region(org.apache.geode.cache.Region) NetworkUtils(org.apache.geode.test.dunit.NetworkUtils) DataOutput(java.io.DataOutput) Iterator(java.util.Iterator) AbstractIndex(org.apache.geode.cache.query.internal.index.AbstractIndex) AvailablePortHelper(org.apache.geode.internal.AvailablePortHelper) RegionShortcut(org.apache.geode.cache.RegionShortcut) Test(org.junit.Test) IOException(java.io.IOException) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) QueryService(org.apache.geode.cache.query.QueryService) CacheException(org.apache.geode.cache.CacheException) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory) PartitionedIndex(org.apache.geode.cache.query.internal.index.PartitionedIndex) SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) SelectResults(org.apache.geode.cache.query.SelectResults) JUnit4CacheTestCase(org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase) PdxReader(org.apache.geode.pdx.PdxReader) IndexNameConflictException(org.apache.geode.cache.query.IndexNameConflictException) TypeMismatchException(org.apache.geode.cache.query.TypeMismatchException) Assert(org.junit.Assert) IndexExistsException(org.apache.geode.cache.query.IndexExistsException) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) Cache(org.apache.geode.cache.Cache) ClientCache(org.apache.geode.cache.client.ClientCache) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) Test(org.junit.Test)

Aggregations

SerializableRunnableIF (org.apache.geode.test.dunit.SerializableRunnableIF)49 Test (org.junit.Test)45 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)44 Parameters (junitparams.Parameters)39 Cache (org.apache.geode.cache.Cache)12 Region (org.apache.geode.cache.Region)12 List (java.util.List)7 ClientCache (org.apache.geode.cache.client.ClientCache)6 Host (org.apache.geode.test.dunit.Host)6 VM (org.apache.geode.test.dunit.VM)6 ArrayList (java.util.ArrayList)5 CacheException (org.apache.geode.cache.CacheException)5 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)5 AbstractIndex (org.apache.geode.cache.query.internal.index.AbstractIndex)5 IOException (java.io.IOException)4 Collection (java.util.Collection)4 HashSet (java.util.HashSet)4 CancellationException (java.util.concurrent.CancellationException)4 DataInput (java.io.DataInput)3 DataOutput (java.io.DataOutput)3