geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From esh...@apache.org
Subject geode git commit: GEODE-2847: Get correct version tags for retried bulk operations
Date Wed, 03 May 2017 17:09:27 GMT
Repository: geode
Updated Branches:
  refs/heads/develop 480a1e05c -> 0dd2552b1


GEODE-2847: Get correct version tags for retried bulk operations

Get correct version tags from recordedBulkOpVersionTags in eventTracker.
Do not remove the recordedBulkOpVersionTags prematurely.
Add the unit test which would fail without the fixes.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/0dd2552b
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/0dd2552b
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/0dd2552b

Branch: refs/heads/develop
Commit: 0dd2552b111423ddb1662c30a33c0eacc15eb087
Parents: 480a1e0
Author: eshu <eshu@pivotal.io>
Authored: Wed May 3 10:07:53 2017 -0700
Committer: eshu <eshu@pivotal.io>
Committed: Wed May 3 10:07:53 2017 -0700

----------------------------------------------------------------------
 .../geode/internal/cache/EventTrackerTest.java  | 94 ++++++++++++++++++++
 1 file changed, 94 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/0dd2552b/geode-core/src/test/java/org/apache/geode/internal/cache/EventTrackerTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/EventTrackerTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/EventTrackerTest.java
new file mode 100644
index 0000000..d74b3d5
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/EventTrackerTest.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information
regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version
2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain
a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under
the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express
+ * or implied. See the License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+
+package org.apache.geode.internal.cache;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import java.util.concurrent.ConcurrentMap;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.apache.geode.CancelCriterion;
+import org.apache.geode.cache.DataPolicy;
+import org.apache.geode.cache.Operation;
+import org.apache.geode.cache.RegionAttributes;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.internal.cache.EventTracker.BulkOpHolder;
+import org.apache.geode.internal.cache.ha.ThreadIdentifier;
+import org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID;
+import org.apache.geode.internal.cache.versions.VersionTag;
+import org.apache.geode.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class EventTrackerTest {
+  LocalRegion lr;
+  RegionAttributes<?, ?> ra;
+  EntryEventImpl[] events;
+  EventTracker eventTracker;
+  ClientProxyMembershipID memberId;
+  DistributedMember member;
+
+  @Before
+  public void setUp() {
+    lr = mock(LocalRegion.class);
+    ra = mock(RegionAttributes.class);
+    when(lr.createStopper()).thenCallRealMethod();
+    CancelCriterion stopper = lr.createStopper();
+    when(lr.getStopper()).thenReturn(stopper);
+    memberId = mock(ClientProxyMembershipID.class);
+    when(lr.getAttributes()).thenReturn(ra);
+    when(ra.getDataPolicy()).thenReturn(mock(DataPolicy.class));
+    when(lr.getConcurrencyChecksEnabled()).thenReturn(true);
+
+    member = mock(DistributedMember.class);
+  }
+
+  @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);
+  }
+
+  private void recordPutAllEvents(byte[] memId, long threadId, boolean skipCallbacks, int
size) {
+    events = new EntryEventImpl[size];
+    eventTracker = new EventTracker(lr);
+    for (int i = 0; i < size; i++) {
+      events[i] = EntryEventImpl.create(lr, Operation.PUTALL_CREATE, "key" + i, "value" +
i, null,
+          false, member, !skipCallbacks, new EventID(memId, threadId, i + 1));
+      events[i].setContext(memberId);
+      events[i].setVersionTag(mock(VersionTag.class));
+      eventTracker.recordEvent(events[i]);
+    }
+  }
+}


Mime
View raw message