Search in sources :

Example 1 with BulkOpHolder

use of org.apache.geode.internal.cache.EventTracker.BulkOpHolder in project geode by apache.

the class DistributedRegionJUnitTest method retriedBulkOpGetsSavedVersionTag.

@Test
public void retriedBulkOpGetsSavedVersionTag() {
    DistributedRegion region = prepare(true, true);
    DistributedMember member = mock(DistributedMember.class);
    ClientProxyMembershipID memberId = mock(ClientProxyMembershipID.class);
    doReturn(false).when(region).isUsedForPartitionedRegionBucket();
    byte[] memId = { 1, 2, 3 };
    long threadId = 1;
    long retrySeqId = 1;
    ThreadIdentifier tid = new ThreadIdentifier(memId, threadId);
    EventID retryEventID = new EventID(memId, threadId, retrySeqId);
    boolean skipCallbacks = true;
    int size = 2;
    recordPutAllEvents(region, memId, threadId, skipCallbacks, member, memberId, size);
    EventTracker eventTracker = region.getEventTracker();
    ConcurrentMap<ThreadIdentifier, BulkOpHolder> map = eventTracker.getRecordedBulkOpVersionTags();
    BulkOpHolder holder = map.get(tid);
    EntryEventImpl retryEvent = EntryEventImpl.create(region, Operation.PUTALL_CREATE, "key1", "value1", null, false, member, !skipCallbacks, retryEventID);
    retryEvent.setContext(memberId);
    retryEvent.setPutAllOperation(mock(DistributedPutAllOperation.class));
    region.hasSeenEvent(retryEvent);
    assertTrue(retryEvent.getVersionTag().equals(holder.entryVersionTags.get(retryEventID)));
}
Also used : ThreadIdentifier(org.apache.geode.internal.cache.ha.ThreadIdentifier) ClientProxyMembershipID(org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID) BulkOpHolder(org.apache.geode.internal.cache.EventTracker.BulkOpHolder) DistributedMember(org.apache.geode.distributed.DistributedMember) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 2 with BulkOpHolder

use of org.apache.geode.internal.cache.EventTracker.BulkOpHolder in project geode by apache.

the class EventTrackerTest method retriedBulkOpDoesNotRemoveRecordedBulkOpVersionTags.

@Test
public void retriedBulkOpDoesNotRemoveRecordedBulkOpVersionTags() {
    byte[] memId = { 1, 2, 3 };
    long threadId = 1;
    long retrySeqId = 1;
    ThreadIdentifier tid = new ThreadIdentifier(memId, threadId);
    EventID retryEventID = new EventID(memId, threadId, retrySeqId);
    boolean skipCallbacks = true;
    int size = 5;
    recordPutAllEvents(memId, threadId, skipCallbacks, size);
    ConcurrentMap<ThreadIdentifier, BulkOpHolder> map = eventTracker.getRecordedBulkOpVersionTags();
    BulkOpHolder holder = map.get(tid);
    int beforeSize = holder.entryVersionTags.size();
    eventTracker.recordBulkOpStart(tid, retryEventID);
    map = eventTracker.getRecordedBulkOpVersionTags();
    holder = map.get(tid);
    // Retried bulk op should not remove exiting BulkOpVersionTags
    assertTrue(holder.entryVersionTags.size() == beforeSize);
}
Also used : BulkOpHolder(org.apache.geode.internal.cache.EventTracker.BulkOpHolder) ThreadIdentifier(org.apache.geode.internal.cache.ha.ThreadIdentifier) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 3 with BulkOpHolder

use of org.apache.geode.internal.cache.EventTracker.BulkOpHolder in project geode by apache.

the class EventTrackerDUnitTest method checkEventTracker.

private void checkEventTracker(LocalRegion region, int numberOfEvents) {
    EventTracker tracker = region.getEventTracker();
    ConcurrentMap<ThreadIdentifier, BulkOpHolder> memberToTags = tracker.getRecordedBulkOpVersionTags();
    assertEquals("memberToTags=" + memberToTags, 1, memberToTags.size());
    BulkOpHolder holder = memberToTags.values().iterator().next();
    // We expect the holder to retain only the last putAll that was performed.
    assertEquals("entryToVersionTags=" + holder.entryVersionTags, numberOfEvents, holder.entryVersionTags.size());
}
Also used : BulkOpHolder(org.apache.geode.internal.cache.EventTracker.BulkOpHolder) ThreadIdentifier(org.apache.geode.internal.cache.ha.ThreadIdentifier)

Aggregations

BulkOpHolder (org.apache.geode.internal.cache.EventTracker.BulkOpHolder)3 ThreadIdentifier (org.apache.geode.internal.cache.ha.ThreadIdentifier)3 UnitTest (org.apache.geode.test.junit.categories.UnitTest)2 Test (org.junit.Test)2 DistributedMember (org.apache.geode.distributed.DistributedMember)1 ClientProxyMembershipID (org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID)1