Search in sources :

Example 11 with GatewaySenderEventImpl

use of org.apache.geode.internal.cache.wan.GatewaySenderEventImpl in project geode by apache.

the class ParallelGatewaySenderQueueJUnitTest method whenGatewayEventUnableToResolveFromOffHeapTheStatForNotQueuedConflatedShouldBeIncremented.

@Test
public void whenGatewayEventUnableToResolveFromOffHeapTheStatForNotQueuedConflatedShouldBeIncremented() throws Exception {
    GatewaySenderStats stats = mockGatewaySenderStats();
    GatewaySenderEventImpl event = mock(GatewaySenderEventImpl.class);
    when(event.makeHeapCopyIfOffHeap()).thenReturn(null);
    GatewaySenderEventImpl eventResolvesFromOffHeap = mock(GatewaySenderEventImpl.class);
    when(eventResolvesFromOffHeap.makeHeapCopyIfOffHeap()).thenReturn(eventResolvesFromOffHeap);
    Queue backingList = new LinkedList();
    backingList.add(event);
    backingList.add(eventResolvesFromOffHeap);
    BucketRegionQueue bucketRegionQueue = mockBucketRegionQueue(backingList);
    TestableParallelGatewaySenderQueue queue = new TestableParallelGatewaySenderQueue(sender, Collections.emptySet(), 0, 1, metaRegionFactory);
    queue.setMockedAbstractBucketRegionQueue(bucketRegionQueue);
    List peeked = queue.peek(1, 1000);
    assertEquals(1, peeked.size());
    verify(stats, times(1)).incEventsNotQueuedConflated();
}
Also used : GatewaySenderStats(org.apache.geode.internal.cache.wan.GatewaySenderStats) BucketRegionQueue(org.apache.geode.internal.cache.BucketRegionQueue) AbstractBucketRegionQueue(org.apache.geode.internal.cache.AbstractBucketRegionQueue) GatewaySenderEventImpl(org.apache.geode.internal.cache.wan.GatewaySenderEventImpl) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) BucketRegionQueue(org.apache.geode.internal.cache.BucketRegionQueue) AbstractBucketRegionQueue(org.apache.geode.internal.cache.AbstractBucketRegionQueue) Queue(java.util.Queue) LinkedList(java.util.LinkedList) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 12 with GatewaySenderEventImpl

use of org.apache.geode.internal.cache.wan.GatewaySenderEventImpl in project geode by apache.

the class ParallelGatewaySenderQueueJUnitTest method whenEventReleaseFromOffHeapFailsExceptionShouldNotBeThrownToAckReaderThread.

@Test
public void whenEventReleaseFromOffHeapFailsExceptionShouldNotBeThrownToAckReaderThread() throws Exception {
    GatewaySenderEventImpl event = mock(GatewaySenderEventImpl.class);
    when(event.makeHeapCopyIfOffHeap()).thenReturn(event);
    Mockito.doThrow(new IllegalStateException()).when(event).release();
    Queue backingList = new LinkedList();
    backingList.add(event);
    BucketRegionQueue bucketRegionQueue = mockBucketRegionQueue(backingList);
    TestableParallelGatewaySenderQueue queue = new TestableParallelGatewaySenderQueue(sender, Collections.emptySet(), 0, 1, metaRegionFactory);
    queue.setMockedAbstractBucketRegionQueue(bucketRegionQueue);
    List peeked = queue.peek(1, 1000);
    assertEquals(1, peeked.size());
    queue.remove();
}
Also used : BucketRegionQueue(org.apache.geode.internal.cache.BucketRegionQueue) AbstractBucketRegionQueue(org.apache.geode.internal.cache.AbstractBucketRegionQueue) GatewaySenderEventImpl(org.apache.geode.internal.cache.wan.GatewaySenderEventImpl) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) BucketRegionQueue(org.apache.geode.internal.cache.BucketRegionQueue) AbstractBucketRegionQueue(org.apache.geode.internal.cache.AbstractBucketRegionQueue) Queue(java.util.Queue) LinkedList(java.util.LinkedList) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 13 with GatewaySenderEventImpl

use of org.apache.geode.internal.cache.wan.GatewaySenderEventImpl in project geode by apache.

the class ParallelGatewaySenderQueueJUnitTest method whenNullPeekedEventFromBucketRegionQueueTheStatForNotQueuedConflatedShouldBeIncremented.

@Test
public void whenNullPeekedEventFromBucketRegionQueueTheStatForNotQueuedConflatedShouldBeIncremented() throws Exception {
    GatewaySenderStats stats = mockGatewaySenderStats();
    GatewaySenderEventImpl eventResolvesFromOffHeap = mock(GatewaySenderEventImpl.class);
    when(eventResolvesFromOffHeap.makeHeapCopyIfOffHeap()).thenReturn(eventResolvesFromOffHeap);
    Queue backingList = new LinkedList();
    backingList.add(null);
    backingList.add(eventResolvesFromOffHeap);
    BucketRegionQueue bucketRegionQueue = mockBucketRegionQueue(backingList);
    TestableParallelGatewaySenderQueue queue = new TestableParallelGatewaySenderQueue(sender, Collections.emptySet(), 0, 1, metaRegionFactory);
    queue.setMockedAbstractBucketRegionQueue(bucketRegionQueue);
    List peeked = queue.peek(1, 1000);
    assertEquals(1, peeked.size());
    verify(stats, times(1)).incEventsNotQueuedConflated();
}
Also used : GatewaySenderStats(org.apache.geode.internal.cache.wan.GatewaySenderStats) BucketRegionQueue(org.apache.geode.internal.cache.BucketRegionQueue) AbstractBucketRegionQueue(org.apache.geode.internal.cache.AbstractBucketRegionQueue) GatewaySenderEventImpl(org.apache.geode.internal.cache.wan.GatewaySenderEventImpl) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) BucketRegionQueue(org.apache.geode.internal.cache.BucketRegionQueue) AbstractBucketRegionQueue(org.apache.geode.internal.cache.AbstractBucketRegionQueue) Queue(java.util.Queue) LinkedList(java.util.LinkedList) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 14 with GatewaySenderEventImpl

use of org.apache.geode.internal.cache.wan.GatewaySenderEventImpl in project geode by apache.

the class ParallelQueueRemovalMessageJUnitTest method validateDestroyFromBucketQueueAndTempQueueInUninitializedBucketRegionQueue.

@Ignore
@Test
public void validateDestroyFromBucketQueueAndTempQueueInUninitializedBucketRegionQueue() {
    // Validate initial BucketRegionQueue state
    assertFalse(this.bucketRegionQueue.isInitialized());
    assertEquals(0, this.bucketRegionQueue.size());
    // Create a real ConcurrentParallelGatewaySenderQueue
    ParallelGatewaySenderEventProcessor processor = createConcurrentParallelGatewaySenderQueue();
    // Add an event to the BucketRegionQueue and verify BucketRegionQueue state
    GatewaySenderEventImpl event = this.bucketRegionQueueHelper.addEvent(KEY);
    assertEquals(1, this.bucketRegionQueue.size());
    // Add a mock GatewaySenderEventImpl to the temp queue
    BlockingQueue<GatewaySenderEventImpl> tempQueue = createTempQueueAndAddEvent(processor, event);
    assertEquals(1, tempQueue.size());
    // Create and process a ParallelQueueRemovalMessage (causes the value of the entry to be set to
    // DESTROYED)
    when(this.queueRegion.getKeyInfo(KEY, null, null)).thenReturn(new KeyInfo(KEY, null, null));
    createAndProcessParallelQueueRemovalMessage();
    // Validate temp queue is empty after processing ParallelQueueRemovalMessage
    assertEquals(0, tempQueue.size());
    // Clean up destroyed tokens
    this.bucketRegionQueueHelper.cleanUpDestroyedTokensAndMarkGIIComplete();
    // Validate BucketRegionQueue is empty after processing ParallelQueueRemovalMessage
    assertEquals(0, this.bucketRegionQueue.size());
}
Also used : KeyInfo(org.apache.geode.internal.cache.KeyInfo) GatewaySenderEventImpl(org.apache.geode.internal.cache.wan.GatewaySenderEventImpl) Ignore(org.junit.Ignore) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 15 with GatewaySenderEventImpl

use of org.apache.geode.internal.cache.wan.GatewaySenderEventImpl in project geode by apache.

the class AbstractRegionMap method setOldValueInEvent.

// PRECONDITION: caller must be synced on re
private void setOldValueInEvent(EntryEventImpl event, RegionEntry re, boolean cacheWrite, boolean requireOldValue) {
    boolean needToSetOldValue = cacheWrite || requireOldValue || event.getOperation().guaranteesOldValue();
    if (needToSetOldValue) {
        if (event.getOperation().guaranteesOldValue()) {
            // In these cases we want to even get the old value from disk if it is not in memory
            ReferenceCountHelper.skipRefCountTracking();
            @Released Object oldValueInVMOrDisk = re.getValueOffHeapOrDiskWithoutFaultIn(event.getLocalRegion());
            ReferenceCountHelper.unskipRefCountTracking();
            try {
                event.setOldValue(oldValueInVMOrDisk, needToSetOldValue);
            } finally {
                OffHeapHelper.releaseWithNoTracking(oldValueInVMOrDisk);
            }
        } else {
            // In these cases only need the old value if it is in memory
            ReferenceCountHelper.skipRefCountTracking();
            @Retained @Released Object // OFFHEAP: re
            oldValueInVM = re._getValueRetain(event.getLocalRegion(), true);
            // synced so can use
            // its ref.
            ReferenceCountHelper.unskipRefCountTracking();
            try {
                event.setOldValue(oldValueInVM, needToSetOldValue);
            } finally {
                OffHeapHelper.releaseWithNoTracking(oldValueInVM);
            }
        }
    } else {
        // if the old value is in memory then if it is a GatewaySenderEventImpl then
        // we want to set the old value.
        @Unretained Object // OFFHEAP _getValue is ok since re is synced and we only use it
        ov = re._getValue();
        // we don't need to worry about ov being compressed.
        if (ov instanceof GatewaySenderEventImpl) {
            event.setOldValue(ov, true);
        }
    }
}
Also used : Released(org.apache.geode.internal.offheap.annotations.Released) Retained(org.apache.geode.internal.offheap.annotations.Retained) GatewaySenderEventImpl(org.apache.geode.internal.cache.wan.GatewaySenderEventImpl) StoredObject(org.apache.geode.internal.offheap.StoredObject) Unretained(org.apache.geode.internal.offheap.annotations.Unretained)

Aggregations

GatewaySenderEventImpl (org.apache.geode.internal.cache.wan.GatewaySenderEventImpl)22 Region (org.apache.geode.cache.Region)5 AbstractBucketRegionQueue (org.apache.geode.internal.cache.AbstractBucketRegionQueue)5 DistributedRegion (org.apache.geode.internal.cache.DistributedRegion)5 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)5 ArrayList (java.util.ArrayList)4 BucketRegionQueue (org.apache.geode.internal.cache.BucketRegionQueue)4 LocalRegion (org.apache.geode.internal.cache.LocalRegion)4 UnitTest (org.apache.geode.test.junit.categories.UnitTest)4 Test (org.junit.Test)4 LinkedList (java.util.LinkedList)3 List (java.util.List)3 Queue (java.util.Queue)3 EventID (org.apache.geode.internal.cache.EventID)3 GatewaySenderStats (org.apache.geode.internal.cache.wan.GatewaySenderStats)3 BucketRegion (org.apache.geode.internal.cache.BucketRegion)2 RegionQueue (org.apache.geode.internal.cache.RegionQueue)2 EventWrapper (org.apache.geode.internal.cache.wan.AbstractGatewaySender.EventWrapper)2 ConcurrentParallelGatewaySenderQueue (org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue)2 StoredObject (org.apache.geode.internal.offheap.StoredObject)2