Search in sources :

Example 1 with IndexRepositorySpy

use of org.apache.geode.cache.lucene.test.IndexRepositorySpy in project geode by apache.

the class LuceneQueriesAccessorBase method addCallbackToMoveBucket.

protected void addCallbackToMoveBucket(VM vm, final DistributedMember destination) {
    vm.invoke(() -> {
        IndexRepositorySpy spy = IndexRepositorySpy.injectSpy();
        spy.beforeWriteIndexRepository(doOnce(key -> moveBucket(destination, key)));
    });
}
Also used : PartitionRegionHelper(org.apache.geode.cache.partition.PartitionRegionHelper) BecomePrimaryBucketResponse(org.apache.geode.internal.cache.partitioned.BecomePrimaryBucketMessage.BecomePrimaryBucketResponse) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) HashMap(java.util.HashMap) Host(org.apache.geode.test.dunit.Host) VM(org.apache.geode.test.dunit.VM) Cache(org.apache.geode.cache.Cache) InitialImageOperation(org.apache.geode.internal.cache.InitialImageOperation) Region(org.apache.geode.cache.Region) Map(java.util.Map) RebalanceResults(org.apache.geode.cache.control.RebalanceResults) INDEX_NAME(org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME) DEFAULT_FIELD(org.apache.geode.cache.lucene.test.LuceneTestUtilities.DEFAULT_FIELD) Assert.fail(org.junit.Assert.fail) DistributedMember(org.apache.geode.distributed.DistributedMember) Assert.assertNotNull(org.junit.Assert.assertNotNull) LuceneIndexFactorySpy(org.apache.geode.cache.lucene.internal.LuceneIndexFactorySpy) Collection(java.util.Collection) IndexRepositorySpy.doOnce(org.apache.geode.cache.lucene.test.IndexRepositorySpy.doOnce) Assert.assertTrue(org.junit.Assert.assertTrue) LuceneIndexImpl(org.apache.geode.cache.lucene.internal.LuceneIndexImpl) REGION_NAME(org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME) BecomePrimaryBucketMessage(org.apache.geode.internal.cache.partitioned.BecomePrimaryBucketMessage) Serializable(java.io.Serializable) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) RebalanceOperation(org.apache.geode.cache.control.RebalanceOperation) Assert.assertEquals(org.junit.Assert.assertEquals) IndexRepositorySpy(org.apache.geode.cache.lucene.test.IndexRepositorySpy) IndexRepositorySpy(org.apache.geode.cache.lucene.test.IndexRepositorySpy)

Example 2 with IndexRepositorySpy

use of org.apache.geode.cache.lucene.test.IndexRepositorySpy in project geode by apache.

the class LuceneQueriesAccessorBase method addCallbackToTriggerRebalance.

protected void addCallbackToTriggerRebalance(VM vm) {
    vm.invoke(() -> {
        IndexRepositorySpy spy = IndexRepositorySpy.injectSpy();
        spy.beforeWriteIndexRepository(doOnce(key -> rebalanceRegion(vm)));
    });
}
Also used : PartitionRegionHelper(org.apache.geode.cache.partition.PartitionRegionHelper) BecomePrimaryBucketResponse(org.apache.geode.internal.cache.partitioned.BecomePrimaryBucketMessage.BecomePrimaryBucketResponse) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) HashMap(java.util.HashMap) Host(org.apache.geode.test.dunit.Host) VM(org.apache.geode.test.dunit.VM) Cache(org.apache.geode.cache.Cache) InitialImageOperation(org.apache.geode.internal.cache.InitialImageOperation) Region(org.apache.geode.cache.Region) Map(java.util.Map) RebalanceResults(org.apache.geode.cache.control.RebalanceResults) INDEX_NAME(org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME) DEFAULT_FIELD(org.apache.geode.cache.lucene.test.LuceneTestUtilities.DEFAULT_FIELD) Assert.fail(org.junit.Assert.fail) DistributedMember(org.apache.geode.distributed.DistributedMember) Assert.assertNotNull(org.junit.Assert.assertNotNull) LuceneIndexFactorySpy(org.apache.geode.cache.lucene.internal.LuceneIndexFactorySpy) Collection(java.util.Collection) IndexRepositorySpy.doOnce(org.apache.geode.cache.lucene.test.IndexRepositorySpy.doOnce) Assert.assertTrue(org.junit.Assert.assertTrue) LuceneIndexImpl(org.apache.geode.cache.lucene.internal.LuceneIndexImpl) REGION_NAME(org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME) BecomePrimaryBucketMessage(org.apache.geode.internal.cache.partitioned.BecomePrimaryBucketMessage) Serializable(java.io.Serializable) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) RebalanceOperation(org.apache.geode.cache.control.RebalanceOperation) Assert.assertEquals(org.junit.Assert.assertEquals) IndexRepositorySpy(org.apache.geode.cache.lucene.test.IndexRepositorySpy) IndexRepositorySpy(org.apache.geode.cache.lucene.test.IndexRepositorySpy)

Example 3 with IndexRepositorySpy

use of org.apache.geode.cache.lucene.test.IndexRepositorySpy in project geode by apache.

the class LuceneQueriesAccessorBase method addCallbackToMovePrimary.

protected void addCallbackToMovePrimary(VM vm, final DistributedMember destination) {
    vm.invoke(() -> {
        IndexRepositorySpy spy = IndexRepositorySpy.injectSpy();
        spy.beforeWriteIndexRepository(doOnce(key -> movePrimary(destination, key)));
    });
}
Also used : PartitionRegionHelper(org.apache.geode.cache.partition.PartitionRegionHelper) BecomePrimaryBucketResponse(org.apache.geode.internal.cache.partitioned.BecomePrimaryBucketMessage.BecomePrimaryBucketResponse) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) HashMap(java.util.HashMap) Host(org.apache.geode.test.dunit.Host) VM(org.apache.geode.test.dunit.VM) Cache(org.apache.geode.cache.Cache) InitialImageOperation(org.apache.geode.internal.cache.InitialImageOperation) Region(org.apache.geode.cache.Region) Map(java.util.Map) RebalanceResults(org.apache.geode.cache.control.RebalanceResults) INDEX_NAME(org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME) DEFAULT_FIELD(org.apache.geode.cache.lucene.test.LuceneTestUtilities.DEFAULT_FIELD) Assert.fail(org.junit.Assert.fail) DistributedMember(org.apache.geode.distributed.DistributedMember) Assert.assertNotNull(org.junit.Assert.assertNotNull) LuceneIndexFactorySpy(org.apache.geode.cache.lucene.internal.LuceneIndexFactorySpy) Collection(java.util.Collection) IndexRepositorySpy.doOnce(org.apache.geode.cache.lucene.test.IndexRepositorySpy.doOnce) Assert.assertTrue(org.junit.Assert.assertTrue) LuceneIndexImpl(org.apache.geode.cache.lucene.internal.LuceneIndexImpl) REGION_NAME(org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME) BecomePrimaryBucketMessage(org.apache.geode.internal.cache.partitioned.BecomePrimaryBucketMessage) Serializable(java.io.Serializable) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) RebalanceOperation(org.apache.geode.cache.control.RebalanceOperation) Assert.assertEquals(org.junit.Assert.assertEquals) IndexRepositorySpy(org.apache.geode.cache.lucene.test.IndexRepositorySpy) IndexRepositorySpy(org.apache.geode.cache.lucene.test.IndexRepositorySpy)

Example 4 with IndexRepositorySpy

use of org.apache.geode.cache.lucene.test.IndexRepositorySpy in project geode by apache.

the class RebalanceWithRedundancyDUnitTest method returnCorrectResultsWhenCloseCacheHappensOnIndexUpdate.

@Test
@Parameters(method = "getListOfRegionTestTypes")
public void returnCorrectResultsWhenCloseCacheHappensOnIndexUpdate(RegionTestableType regionTestType) throws InterruptedException {
    dataStore1.invoke(() -> {
        IndexRepositorySpy spy = IndexRepositorySpy.injectSpy();
        spy.beforeWriteIndexRepository(doAfterN(key -> getCache().close(), 2));
    });
    final String expectedExceptions = CacheClosedException.class.getName();
    dataStore1.invoke(addExceptionTag1(expectedExceptions));
    putEntriesAndValidateResultsWithRedundancy(regionTestType);
    // Wait until the cache is closed in datastore1
    dataStore1.invoke(() -> Awaitility.await().atMost(60, TimeUnit.SECONDS).until(basicGetCache()::isClosed));
}
Also used : IntStream(java.util.stream.IntStream) GIITestHook(org.apache.geode.internal.cache.InitialImageOperation.GIITestHook) RunWith(org.junit.runner.RunWith) Test(org.junit.Test) IndexRegionSpy(org.apache.geode.cache.lucene.test.IndexRegionSpy) Category(org.junit.experimental.categories.Category) TimeUnit(java.util.concurrent.TimeUnit) Cache(org.apache.geode.cache.Cache) GIITestHookType(org.apache.geode.internal.cache.InitialImageOperation.GIITestHookType) SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) LuceneTestUtilities(org.apache.geode.cache.lucene.test.LuceneTestUtilities) InitialImageOperation(org.apache.geode.internal.cache.InitialImageOperation) CacheClosedException(org.apache.geode.cache.CacheClosedException) Region(org.apache.geode.cache.Region) After(org.junit.After) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) JUnitParamsRunner(junitparams.JUnitParamsRunner) DistributedMember(org.apache.geode.distributed.DistributedMember) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) Assert(org.junit.Assert) Awaitility(org.awaitility.Awaitility) IndexRepositorySpy(org.apache.geode.cache.lucene.test.IndexRepositorySpy) Parameters(junitparams.Parameters) IndexRepositorySpy(org.apache.geode.cache.lucene.test.IndexRepositorySpy) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

TimeUnit (java.util.concurrent.TimeUnit)4 Cache (org.apache.geode.cache.Cache)4 Region (org.apache.geode.cache.Region)4 IndexRepositorySpy (org.apache.geode.cache.lucene.test.IndexRepositorySpy)4 DistributedMember (org.apache.geode.distributed.DistributedMember)4 InitialImageOperation (org.apache.geode.internal.cache.InitialImageOperation)4 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)4 Serializable (java.io.Serializable)3 Collection (java.util.Collection)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 RebalanceOperation (org.apache.geode.cache.control.RebalanceOperation)3 RebalanceResults (org.apache.geode.cache.control.RebalanceResults)3 LuceneIndexFactorySpy (org.apache.geode.cache.lucene.internal.LuceneIndexFactorySpy)3 LuceneIndexImpl (org.apache.geode.cache.lucene.internal.LuceneIndexImpl)3 IndexRepositorySpy.doOnce (org.apache.geode.cache.lucene.test.IndexRepositorySpy.doOnce)3 DEFAULT_FIELD (org.apache.geode.cache.lucene.test.LuceneTestUtilities.DEFAULT_FIELD)3 INDEX_NAME (org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME)3 REGION_NAME (org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME)3