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();
}
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();
}
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();
}
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());
}
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);
}
}
}
Aggregations