geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [7/7] geode git commit: fixup
Date Tue, 25 Apr 2017 23:30:19 GMT
fixup


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

Branch: refs/heads/feature/GEODE-2632-7
Commit: 93ed1771fab07b38f6814a946c43d9beabc82c84
Parents: 674e7da
Author: Kirk Lund <klund@apache.org>
Authored: Tue Apr 25 16:25:35 2017 -0700
Committer: Kirk Lund <klund@apache.org>
Committed: Tue Apr 25 16:25:56 2017 -0700

----------------------------------------------------------------------
 .../geode/internal/cache/DistTXState.java       | 15 +---
 .../geode/internal/cache/GemFireCacheImpl.java  | 22 ++---
 .../NewDeclarativeIndexCreationJUnitTest.java   | 86 ++++++++++----------
 3 files changed, 54 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/93ed1771/geode-core/src/main/java/org/apache/geode/internal/cache/DistTXState.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DistTXState.java b/geode-core/src/main/java/org/apache/geode/internal/cache/DistTXState.java
index 226ffa6..482a834 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DistTXState.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DistTXState.java
@@ -45,26 +45,19 @@ import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.offheap.annotations.Released;
 
 /**
- * TxState on a datanode VM
- * 
- * 
+ * TxState on a data node VM
  */
 public class DistTXState extends TXState {
 
-  public static Runnable internalBeforeApplyChanges;
-  public static Runnable internalBeforeNonTXBasicPut;
+  public static Runnable internalBeforeApplyChanges; // test hook
+  public static Runnable internalBeforeNonTXBasicPut; // test hook
+
   private boolean updatingTxStateDuringPreCommit = false;
 
   public DistTXState(TXStateProxy proxy, boolean onBehalfOfRemoteStub) {
     super(proxy, onBehalfOfRemoteStub);
   }
 
-  @Override
-  protected void cleanup() {
-    super.cleanup();
-    // Do nothing for now
-  }
-
   /*
    * If this is a primary member, for each entry in TXState, generate next region version
and store
    * in the entry.

http://git-wip-us.apache.org/repos/asf/geode/blob/93ed1771/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
index 74ec96c..66f9b9b 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
@@ -649,6 +649,7 @@ public class GemFireCacheImpl
     sb.append("; lockTimeout = ").append(this.lockTimeout);
     if (this.creationStack != null) {
       sb.append(System.lineSeparator()).append("Creation context:").append(System.lineSeparator());
+      // TODO: remove anonymous class and clean this up
       OutputStream os = new OutputStream() {
         @Override
         public void write(int i) {
@@ -2408,10 +2409,7 @@ public class GemFireCacheImpl
   @Override
   public Cache getReconnectedCache() {
     GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-    if (cache == null) {
-      return null;
-    }
-    if (cache == this || !cache.isInitialized()) {
+    if (cache == this || cache != null && !cache.isInitialized()) {
       cache = null;
     }
     return cache;
@@ -4129,17 +4127,15 @@ public class GemFireCacheImpl
 
   @Override
   public QueryService getQueryService() {
-    if (isClient()) {
-      Pool pool = getDefaultPool();
-      if (pool == null) {
-        throw new IllegalStateException(
-            "Client cache does not have a default pool. Use getQueryService(String poolName)
instead.");
-      } else {
-        return pool.getQueryService();
-      }
-    } else {
+    if (!isClient()) {
       return new DefaultQueryService(this);
     }
+    Pool pool = getDefaultPool();
+    if (pool == null) {
+      throw new IllegalStateException(
+          "Client cache does not have a default pool. Use getQueryService(String poolName)
instead.");
+    }
+    return pool.getQueryService();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/geode/blob/93ed1771/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/NewDeclarativeIndexCreationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/NewDeclarativeIndexCreationJUnitTest.java
b/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/NewDeclarativeIndexCreationJUnitTest.java
index e7f5c08..58b8f11 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/NewDeclarativeIndexCreationJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/NewDeclarativeIndexCreationJUnitTest.java
@@ -73,66 +73,65 @@ public class NewDeclarativeIndexCreationJUnitTest {
   }
 
   @Test
-  public void testAsynchronousIndexCreatedOnRoot_PortfoliosRegion() {
-    Region root = this.cache.getRegion("/root/portfolios");
-    IndexManager im = IndexUtils.getIndexManager(root, true);
-    assertThat(im.getIndexes()).isNotEmpty();
+  public void testAsynchronousIndexCreatedOnRoot_PortfoliosRegion() throws Exception {
+    Region<Object, Object> region = this.cache.getRegion("/root/portfolios");
+    IndexManager indexManager = IndexUtils.getIndexManager(region, true);
+    assertThat(indexManager.getIndexes()).isNotEmpty();
 
-    RegionAttributes ra = root.getAttributes();
-    assertThat(ra.getIndexMaintenanceSynchronous()).isFalse();
+    RegionAttributes<Object, Object> regionAttributes = region.getAttributes();
+    assertThat(regionAttributes.getIndexMaintenanceSynchronous()).isFalse();
   }
 
   @Test
-  public void testSynchronousIndexCreatedOnRoot_StringRegion() {
-    Region root = this.cache.getRegion("/root/string");
-    IndexManager im = IndexUtils.getIndexManager(root, true);
-    assertThat(im.getIndexes()).isNotEmpty();
+  public void testSynchronousIndexCreatedOnRoot_StringRegion() throws Exception {
+    Region<Object, Object> region = this.cache.getRegion("/root/string");
+    IndexManager indexManager = IndexUtils.getIndexManager(region, true);
+    assertThat(indexManager.getIndexes()).isNotEmpty();
 
-    RegionAttributes ra = root.getAttributes();
-    assertThat(ra.getIndexMaintenanceSynchronous()).isTrue();
+    RegionAttributes<Object, Object> regionAttributes = region.getAttributes();
+    assertThat(regionAttributes.getIndexMaintenanceSynchronous()).isTrue();
 
-    root = this.cache.getRegion("/root/string1");
-    im = IndexUtils.getIndexManager(root, true);
-    assertThat(im.isIndexMaintenanceTypeSynchronous()).isTrue();
+    region = this.cache.getRegion("/root/string1");
+    indexManager = IndexUtils.getIndexManager(region, true);
+    assertThat(indexManager.isIndexMaintenanceTypeSynchronous()).isTrue();
   }
 
   @Test
-  public void testSynchronousIndexCreatedOnRootRegion() {
-    Region root = this.cache.getRegion("/root");
-    IndexManager im = IndexUtils.getIndexManager(root, true);
-    assertThat(im.getIndexes()).isNotEmpty();
+  public void testSynchronousIndexCreatedOnRootRegion() throws Exception {
+    Region<Object, Object> region = this.cache.getRegion("/root");
+    IndexManager indexManager = IndexUtils.getIndexManager(region, true);
+    assertThat(indexManager.getIndexes()).isNotEmpty();
 
-    RegionAttributes ra = root.getAttributes();
-    assertThat(ra.getIndexMaintenanceSynchronous()).isTrue();
+    RegionAttributes<Object, Object> regionAttributes = region.getAttributes();
+    assertThat(regionAttributes.getIndexMaintenanceSynchronous()).isTrue();
   }
 
-
   /**
    * Index creation tests for new DTD changes for Index tag for 6.6.1 with no function/primary-key
    * tag
    */
   @Test
-  public void testAsynchronousIndexCreatedOnPortfoliosRegionWithNewDTD() {
-    Region root = this.cache.getRegion("/root/portfolios2");
-    IndexManager im = IndexUtils.getIndexManager(root, true);
-    assertThat(im.getIndexes()).isNotEmpty();
+  public void testAsynchronousIndexCreatedOnPortfoliosRegionWithNewDTD() throws Exception
{
+    Region<Object, Object> region = this.cache.getRegion("/root/portfolios2");
+    IndexManager indexManager = IndexUtils.getIndexManager(region, true);
+    assertThat(indexManager.getIndexes()).isNotEmpty();
 
-    RegionAttributes ra = root.getAttributes();
-    assertThat(ra.getIndexMaintenanceSynchronous()).isFalse();
+    RegionAttributes<Object, Object> regionAttributes = region.getAttributes();
+    assertThat(regionAttributes.getIndexMaintenanceSynchronous()).isFalse();
   }
 
   @Test
-  public void testSynchronousIndexCreatedOnStringRegionWithNewDTD() {
-    Region root = this.cache.getRegion("/root/string2");
-    IndexManager im = IndexUtils.getIndexManager(root, true);;
-    assertThat(im.getIndexes()).isNotEmpty();
+  public void testSynchronousIndexCreatedOnStringRegionWithNewDTD() throws Exception {
+    Region<Object, Object> region = this.cache.getRegion("/root/string2");
+    IndexManager indexManager = IndexUtils.getIndexManager(region, true);;
+    assertThat(indexManager.getIndexes()).isNotEmpty();
 
-    RegionAttributes ra = root.getAttributes();
-    assertThat(ra.getIndexMaintenanceSynchronous()).isTrue();
+    RegionAttributes<Object, Object> regionAttributes = region.getAttributes();
+    assertThat(regionAttributes.getIndexMaintenanceSynchronous()).isTrue();
 
-    root = this.cache.getRegion("/root/string1");
-    im = IndexUtils.getIndexManager(root, true);
-    assertThat(im.isIndexMaintenanceTypeSynchronous()).isTrue();
+    region = this.cache.getRegion("/root/string1");
+    indexManager = IndexUtils.getIndexManager(region, true);
+    assertThat(indexManager.isIndexMaintenanceTypeSynchronous()).isTrue();
   }
 
   /**
@@ -149,17 +148,14 @@ public class NewDeclarativeIndexCreationJUnitTest {
         this.cacheXmlFile);
     assertThat(this.cacheXmlFile).exists(); // precondition
 
-    Properties props = new Properties();
-    props.setProperty(CACHE_XML_FILE, this.cacheXmlFile.getAbsolutePath());
-    props.setProperty(MCAST_PORT, "0");
+    Properties properties = new Properties();
+    properties.setProperty(CACHE_XML_FILE, this.cacheXmlFile.getAbsolutePath());
+    properties.setProperty(MCAST_PORT, "0");
 
-    DistributedSystem ds = DistributedSystem.connect(props);
+    DistributedSystem system = DistributedSystem.connect(properties);
 
     // TODO: refactoring GemFireCacheImpl.initializeDeclarativeCache requires change here
-    assertThatThrownBy(() -> CacheFactory.create(ds)).isExactlyInstanceOf(CacheXmlException.class)
+    assertThatThrownBy(() -> CacheFactory.create(system)).isExactlyInstanceOf(CacheXmlException.class)
         .hasCauseInstanceOf(InternalGemFireException.class);
-
-    // hasCauseMessageContaining("CacheXmlParser::endIndex:Index creation attribute not correctly
-    // specified.");
   }
 }


Mime
View raw message