You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by sb...@apache.org on 2016/02/25 19:41:36 UTC
incubator-geode git commit: GEODE-983: NPE with transactions on PR
with overflow
Repository: incubator-geode
Updated Branches:
refs/heads/develop d50623b04 -> deaa7aa68
GEODE-983: NPE with transactions on PR with overflow
Use a BucketRegion while faulting-in an overflowed value.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/deaa7aa6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/deaa7aa6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/deaa7aa6
Branch: refs/heads/develop
Commit: deaa7aa68e368b26d8fea203d5273a37e7892a2a
Parents: d50623b
Author: Swapnil Bawaskar <sb...@pivotal.io>
Authored: Wed Feb 24 17:26:20 2016 -0800
Committer: Swapnil Bawaskar <sb...@pivotal.io>
Committed: Thu Feb 25 10:06:49 2016 -0800
----------------------------------------------------------------------
.../gemfire/internal/cache/TXState.java | 4 +-
.../cache/lru/TransactionsWithOverflowTest.java | 85 ++++++++++++++++++++
2 files changed, 87 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/deaa7aa6/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java
index 8215957..02237b7 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/TXState.java
@@ -1362,7 +1362,7 @@ public class TXState implements TXStateInterface {
if (txr == null) {
txr = txWriteRegion(localRegion, keyInfo);
}
- result = localRegion.createReadEntry(txr, keyInfo, createIfAbsent);
+ result = dataReg.createReadEntry(txr, keyInfo, createIfAbsent);
}
if (result != null) {
@@ -1379,7 +1379,7 @@ public class TXState implements TXStateInterface {
*
*/
if (txr!=null) {
- txr.cleanupNonDirtyEntries(localRegion);
+ txr.cleanupNonDirtyEntries(dataReg);
}
if (expectedOldValue==null) {
/*
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/deaa7aa6/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/lru/TransactionsWithOverflowTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/lru/TransactionsWithOverflowTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/lru/TransactionsWithOverflowTest.java
new file mode 100644
index 0000000..fc906b6
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/lru/TransactionsWithOverflowTest.java
@@ -0,0 +1,85 @@
+/*
+ * 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 com.gemstone.gemfire.internal.cache.lru;
+
+import com.gemstone.gemfire.cache.*;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
+
+import java.io.File;
+import java.util.Properties;
+
+/**
+ * Test for transactional operations on overflowed data
+ */
+@Category(IntegrationTest.class)
+public class TransactionsWithOverflowTest {
+
+ @Rule
+ public TestName name = new TestName();
+
+ private Cache cache;
+
+ private String createDiskStoreAndGetName() {
+ Cache cache = getCache();
+ File[] diskDirs = new File[1];
+ diskDirs[0] = new File("diskRegionDirs/"+getClass().getCanonicalName());
+ diskDirs[0].mkdirs();
+ DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory();
+ diskStoreFactory.setDiskDirs(diskDirs);
+ String diskStoreName = getClass().getName();
+ diskStoreFactory.create(diskStoreName);
+ return diskStoreName;
+ }
+
+ @Test
+ public void testpartitionedRegionWithOverflow() {
+ Cache cache = getCache();
+ String diskStoreName = createDiskStoreAndGetName();
+ Region pr = createOverflowPR(cache, diskStoreName);
+ for (int i=0; i<5;i++) {
+ pr.put(i, "value"+i);
+ }
+ CacheTransactionManager mgr = cache.getCacheTransactionManager();
+ mgr.begin();
+ pr.destroy(1);
+ mgr.commit();
+ }
+
+ private Cache getCache() {
+ if (cache == null) {
+ Properties props = new Properties();
+ props.setProperty("locators", "");
+ props.setProperty("mcast-port","0");
+ cache = new CacheFactory(props).create();
+ }
+ return cache;
+ }
+
+ private Region createOverflowPR(Cache cache, String diskStoreName) {
+ RegionFactory rf = cache.createRegionFactory();
+ rf.setDataPolicy(DataPolicy.PARTITION);
+ rf.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK));
+ rf.setPartitionAttributes(new PartitionAttributesFactory().setTotalNumBuckets(1).create());
+ rf.setDiskStoreName(diskStoreName);
+ return rf.create(name.getMethodName());
+ }
+}
\ No newline at end of file