You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by es...@apache.org on 2018/05/09 18:46:07 UTC

[geode] branch develop updated: Revert "GEODE-5173: Transaction will fault in value from disk if value is Tok… (#1925)"

This is an automated email from the ASF dual-hosted git repository.

eshu11 pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new eb6055e  Revert "GEODE-5173: Transaction will fault in value from disk if value is Tok… (#1925)"
eb6055e is described below

commit eb6055e9db64d008cdee0c0d96e8aed90ccd1faf
Author: eshu <es...@pivotal.io>
AuthorDate: Wed May 9 11:34:26 2018 -0700

    Revert "GEODE-5173: Transaction will fault in value from disk if value is Tok… (#1925)"
    
    This reverts commit 99074c6314f917437af4bbae76be21ddc3dde78a.
---
 .../geode/internal/cache/InternalRegion.java       |   2 +-
 .../apache/geode/internal/cache/LocalRegion.java   |  22 ++-
 .../PersistentRegionTransactionDUnitTest.java      | 210 ---------------------
 3 files changed, 14 insertions(+), 220 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/InternalRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/InternalRegion.java
index ecda8c3..6b3f4a0 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/InternalRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/InternalRegion.java
@@ -314,7 +314,7 @@ public interface InternalRegion extends Region, HasCachePerfStats, RegionEntryCo
 
   void setInUseByTransaction(boolean b);
 
-  boolean txLRUStart();
+  void txLRUStart();
 
   void txLRUEnd();
 
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
index 4c58c2e..fe12140 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
@@ -8334,15 +8334,19 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
       try {
         synchronized (regionEntry) {
           if (!regionEntry.isRemoved()) {
-            Object value = regionEntry.getValueInVM(this);
-            if (value == Token.NOT_AVAILABLE) {
-              // Entry value is on disk
-              // Handle the case where we fault in a evicted disk entry
-              needsLRUCleanup = txLRUStart();
-              // Fault in the value from disk
-              value = regionEntry.getValue(this);
+            if (regionEntry instanceof DiskEntry && regionEntry instanceof EvictableEntry) {
+              EvictableEntry le = (EvictableEntry) regionEntry;
+              if (le.isEvicted()) {
+                // Handle the case where we fault in a disk entry
+                txLRUStart();
+                needsLRUCleanup = true;
+
+                // Fault in the value from disk
+                regionEntry.getValue(this);
+              }
             }
 
+            Object value = regionEntry.getValueInVM(this);
             /*
              * The tx will need the raw value for identity comparison. Please see
              * TXEntryState#checkForConflict(LocalRegion,Object)
@@ -8442,8 +8446,8 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
   }
 
   @Override
-  public boolean txLRUStart() {
-    return this.entries.disableLruUpdateCallback();
+  public void txLRUStart() {
+    this.entries.disableLruUpdateCallback();
   }
 
   @Override
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/PersistentRegionTransactionDUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/PersistentRegionTransactionDUnitTest.java
deleted file mode 100644
index bb356dc..0000000
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/PersistentRegionTransactionDUnitTest.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * 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 java.util.concurrent.TimeUnit.SECONDS;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-
-import java.util.stream.IntStream;
-
-import org.awaitility.Awaitility;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.cache.EvictionAction;
-import org.apache.geode.cache.EvictionAttributes;
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.cache.client.ClientCache;
-import org.apache.geode.cache.client.ClientCacheFactory;
-import org.apache.geode.cache.client.ClientRegionShortcut;
-import org.apache.geode.cache.server.CacheServer;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
-import org.apache.geode.test.dunit.rules.DistributedRestoreSystemProperties;
-import org.apache.geode.test.junit.categories.DistributedTest;
-
-@Category(DistributedTest.class)
-public class PersistentRegionTransactionDUnitTest extends JUnit4CacheTestCase {
-
-  private VM server;
-  private VM client;
-  private final int KEY = 5;
-  private final String VALUE = "value 5";
-  private final String REGIONNAME = "region";
-
-  @Rule
-  public DistributedRestoreSystemProperties restoreSystemProperties =
-      new DistributedRestoreSystemProperties();
-
-
-  @Before
-  public void allowTransactions() {
-    server = VM.getVM(0);
-    client = VM.getVM(1);
-    server.invoke(() -> TXManagerImpl.ALLOW_PERSISTENT_TRANSACTIONS = true);
-  }
-
-  @After
-  public void disallowTransactions() {
-    server.invoke(() -> TXManagerImpl.ALLOW_PERSISTENT_TRANSACTIONS = false);
-
-  }
-
-  @Test
-  public void clientTransactionCanGetNotRecoveredEntryOnPersistentOverflowRegion()
-      throws Exception {
-    createServer(server, true);
-    putData(server);
-    server.invoke(() -> getCache().close());
-    int port = createServer(server, true);
-
-
-    client.invoke(() -> {
-      ClientCacheFactory factory = new ClientCacheFactory().addPoolServer("localhost", port);
-      ClientCache cache = getClientCache(factory);
-      cache.getCacheTransactionManager().begin();
-      try {
-        assertEquals(VALUE, cache.createClientRegionFactory(ClientRegionShortcut.PROXY)
-            .create(REGIONNAME).get(KEY));
-      } finally {
-        cache.getCacheTransactionManager().rollback();
-      }
-    });
-  }
-
-  private void putData(final VM server) {
-    server.invoke(() -> {
-      IntStream.range(0, 20)
-          .forEach(index -> getCache().getRegion(REGIONNAME).put(index, "value " + index));
-    });
-  }
-
-  private int createServer(final VM server, boolean isOverflow) {
-    return server.invoke(() -> {
-      if (!isOverflow) {
-        System.setProperty(DiskStoreImpl.RECOVER_VALUE_PROPERTY_NAME, "false");
-      }
-      CacheFactory cacheFactory = new CacheFactory();
-      Cache cache = getCache(cacheFactory);
-      if (isOverflow) {
-        cache.createRegionFactory(RegionShortcut.REPLICATE_PERSISTENT)
-            .setEvictionAttributes(
-                EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK))
-            .create(REGIONNAME);
-      } else {
-        cache.createRegionFactory(RegionShortcut.REPLICATE_PERSISTENT).create(REGIONNAME);
-      }
-      CacheServer cacheServer = cache.addCacheServer();
-      cacheServer.start();
-      return cacheServer.getPort();
-    });
-  }
-
-  @Test
-  public void clientTransactionCanGetEvictedEntryOnPersistentOverflowRegion() throws Exception {
-    int port = createServer(server, true);
-    putData(server);
-    client.invoke(() -> {
-      ClientCacheFactory factory = new ClientCacheFactory().addPoolServer("localhost", port);
-      ClientCache cache = getClientCache(factory);
-      cache.getCacheTransactionManager().begin();
-      try {
-        assertEquals(VALUE, cache.createClientRegionFactory(ClientRegionShortcut.PROXY)
-            .create(REGIONNAME).get(KEY));
-      } finally {
-        cache.getCacheTransactionManager().rollback();
-      }
-    });
-  }
-
-  @Test
-  public void transactionCanGetEvictedEntryOnPersistentOverflowRegion() throws Exception {
-    createServer(server, true);
-    putData(server);
-    server.invoke(() -> {
-      LocalRegion region = (LocalRegion) getCache().getRegion(REGIONNAME);
-      Awaitility.await().atMost(10, SECONDS)
-          .until(() -> assertThat(region.getValueInVM(KEY)).isNull());
-      getCache().getCacheTransactionManager().begin();
-      try {
-        assertEquals(VALUE, region.get(KEY));
-      } finally {
-        cache.getCacheTransactionManager().rollback();
-      }
-    });
-  }
-
-  @Test
-  public void transactionCanGetNotRecoveredEntryOnPersistentOverflowRegion() throws Exception {
-    createServer(server, true);
-    putData(server);
-    server.invoke(() -> getCache().close());
-    createServer(server, true);
-    server.invoke(() -> {
-      LocalRegion region = (LocalRegion) getCache().getRegion("region");
-      getCache().getCacheTransactionManager().begin();
-      try {
-        assertEquals(VALUE, region.get(KEY));
-      } finally {
-        cache.getCacheTransactionManager().rollback();
-      }
-    });
-  }
-
-  @Test
-  public void TransactionCanGetNotRecoveredEntryOnPersistentRegion() throws Exception {
-    createServer(server, false);
-    putData(server);
-    server.invoke(() -> getCache().close());
-    createServer(server, false);
-    server.invoke(() -> {
-      LocalRegion region = (LocalRegion) getCache().getRegion("region");
-      assertThat(region.getValueInVM(KEY)).isNull();
-      getCache().getCacheTransactionManager().begin();
-      try {
-        assertEquals(VALUE, region.get(KEY));
-      } finally {
-        cache.getCacheTransactionManager().rollback();
-      }
-    });
-  }
-
-  @Test
-  public void clientTransactionCanGetNotRecoveredEntryOnPersistentRegion() throws Exception {
-    createServer(server, false);
-    putData(server);
-    server.invoke(() -> getCache().close());
-    int port = createServer(server, false);
-
-
-    client.invoke(() -> {
-      ClientCacheFactory factory = new ClientCacheFactory().addPoolServer("localhost", port);
-      ClientCache cache = getClientCache(factory);
-      cache.getCacheTransactionManager().begin();
-      try {
-        assertEquals(VALUE, cache.createClientRegionFactory(ClientRegionShortcut.PROXY)
-            .create(REGIONNAME).get(KEY));
-      } finally {
-        cache.getCacheTransactionManager().rollback();
-      }
-    });
-  }
-}

-- 
To stop receiving notification emails like this one, please contact
eshu11@apache.org.