geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject [1/3] incubator-geode git commit: starting unit test; still does not work
Date Thu, 19 May 2016 00:02:59 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-1246 [created] 087115556


starting unit test; still does not work


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

Branch: refs/heads/feature/GEODE-1246
Commit: edabd633fe2daeb8375f67dfe18acf1a52bb08b5
Parents: 46056a6
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Wed May 18 09:23:38 2016 -0700
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Wed May 18 09:23:38 2016 -0700

----------------------------------------------------------------------
 .../internal/cache/GemFireCacheImpl.java        | 30 ++++++++++--------
 .../gemfire/internal/cache/LocalRegion.java     |  2 +-
 .../gemfire/internal/jndi/JNDIInvoker.java      |  3 +-
 .../internal/cache/GemFireCacheImplTest.java    | 33 ++++++++++++++++++++
 4 files changed, 52 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/edabd633/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java
index 96b7bbc..d642daa 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java
@@ -270,9 +270,9 @@ public class GemFireCacheImpl implements InternalCache, ClientCache, HasCachePer
   private static final Set<CacheLifecycleListener> cacheLifecycleListeners = new HashSet<CacheLifecycleListener>();
 
   /**
-   * Define LocalRegion.ASYNC_EVENT_LISTENERS=true to invoke event listeners in the background
+   * Define gemfire.Cache.ASYNC_EVENT_LISTENERS=true to invoke event listeners in the background
    */
-  public static final boolean ASYNC_EVENT_LISTENERS = Boolean.getBoolean("gemfire.Cache.ASYNC_EVENT_LISTENERS");
+  private static final boolean ASYNC_EVENT_LISTENERS = Boolean.getBoolean("gemfire.Cache.ASYNC_EVENT_LISTENERS");
 
   /**
    * If true then when a delta is applied the size of the entry value will be recalculated.
If false (the default) then
@@ -763,18 +763,22 @@ public class GemFireCacheImpl implements InternalCache, ClientCache,
HasCachePer
   // }
 
   public static GemFireCacheImpl createClient(DistributedSystem system, PoolFactory pf, CacheConfig
cacheConfig) {
-    return basicCreate(system, true, cacheConfig, pf, true);
+    return basicCreate(system, true, cacheConfig, pf, true, ASYNC_EVENT_LISTENERS);
   }
 
   public static GemFireCacheImpl create(DistributedSystem system, CacheConfig cacheConfig)
{
-    return basicCreate(system, true, cacheConfig, null, false);
+    return basicCreate(system, true, cacheConfig, null, false, ASYNC_EVENT_LISTENERS);
   }
 
-  public static Cache create(DistributedSystem system, boolean existingOk, CacheConfig cacheConfig)
{
-    return basicCreate(system, existingOk, cacheConfig, null, false);
+  public static GemFireCacheImpl createWithAsyncEventListeners(DistributedSystem system,
CacheConfig cacheConfig) {
+    return basicCreate(system, true, cacheConfig, null, false, true);
+  }
+  
+ public static Cache create(DistributedSystem system, boolean existingOk, CacheConfig cacheConfig)
{
+    return basicCreate(system, existingOk, cacheConfig, null, false, ASYNC_EVENT_LISTENERS);
   }
 
-  private static GemFireCacheImpl basicCreate(DistributedSystem system, boolean existingOk,
CacheConfig cacheConfig, PoolFactory pf, boolean isClient)
+  private static GemFireCacheImpl basicCreate(DistributedSystem system, boolean existingOk,
CacheConfig cacheConfig, PoolFactory pf, boolean isClient, boolean asyncEventListeners)
   throws CacheExistsException, TimeoutException, CacheWriterException,
   GatewayException,
   RegionExistsException 
@@ -782,7 +786,7 @@ public class GemFireCacheImpl implements InternalCache, ClientCache, HasCachePer
     try {
       GemFireCacheImpl instance = checkExistingCache(existingOk, cacheConfig);
       if (instance == null) {
-        instance = new GemFireCacheImpl(isClient, pf, system, cacheConfig);
+        instance = new GemFireCacheImpl(isClient, pf, system, cacheConfig, asyncEventListeners);
         instance.initialize();
       }
       return instance;
@@ -814,7 +818,7 @@ public class GemFireCacheImpl implements InternalCache, ClientCache, HasCachePer
   /**
    * Creates a new instance of GemFireCache and populates it according to the <code>cache.xml</code>,
if appropriate.
    */
-  private GemFireCacheImpl(boolean isClient, PoolFactory pf, DistributedSystem system, CacheConfig
cacheConfig) {
+  private GemFireCacheImpl(boolean isClient, PoolFactory pf, DistributedSystem system, CacheConfig
cacheConfig, boolean asyncEventListeners) {
     this.isClient = isClient;
     this.clientpf = pf;
     this.cacheConfig = cacheConfig; // do early for bug 43213
@@ -825,7 +829,7 @@ public class GemFireCacheImpl implements InternalCache, ClientCache, HasCachePer
       
       // start JTA transaction manager within this synchronized block
       // to prevent race with cache close. fixes bug 43987
-      JNDIInvoker.mapTransactions();
+      JNDIInvoker.mapTransactions(system);
       this.system = (InternalDistributedSystem) system;
       this.dm = this.system.getDistributionManager();
       if (!this.isClient && PoolManager.getAll().isEmpty()) {
@@ -868,7 +872,7 @@ public class GemFireCacheImpl implements InternalCache, ClientCache, HasCachePer
 
       this.persistentMemberManager = new PersistentMemberManager();
 
-      if (ASYNC_EVENT_LISTENERS) {
+      if (asyncEventListeners) {
         final ThreadGroup group = LoggingThreadGroup.createThreadGroup("Message Event Threads",logger);
         ThreadFactory tf = new ThreadFactory() {
           public Thread newThread(final Runnable command) {
@@ -2078,7 +2082,7 @@ public class GemFireCacheImpl implements InternalCache, ClientCache,
HasCachePer
 
         destroyGatewaySenderLockService();
 
-        if (ASYNC_EVENT_LISTENERS) {
+        if (this.eventThreadPool != null) {
           if (isDebugEnabled) {
             logger.debug("{}: stopping event thread pool...", this);
           }
@@ -3812,11 +3816,11 @@ public class GemFireCacheImpl implements InternalCache, ClientCache,
HasCachePer
 
   /**
    * Returns the <code>Executor</code> (thread pool) that is used to execute
cache event listeners.
+   * Returns <code>null</code> if no pool exists.
    *
    * @since 3.5
    */
   Executor getEventThreadPool() {
-    Assert.assertTrue(this.eventThreadPool != null);
     return this.eventThreadPool;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/edabd633/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
index b5ff7ee..d28496c 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
@@ -7582,7 +7582,7 @@ public class LocalRegion extends AbstractRegion
           }
         }
         
-        if (!GemFireCacheImpl.ASYNC_EVENT_LISTENERS) {
+        if (this.cache.getEventThreadPool() == null) {
           dispatchEvent(this, event, op);
         }
         else {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/edabd633/geode-core/src/main/java/com/gemstone/gemfire/internal/jndi/JNDIInvoker.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/jndi/JNDIInvoker.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/jndi/JNDIInvoker.java
index b3aecc4..2743537 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/jndi/JNDIInvoker.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/jndi/JNDIInvoker.java
@@ -125,9 +125,8 @@ public class JNDIInvoker  {
    * </p>
    *  
    */
-  public static void mapTransactions() {
+  public static void mapTransactions(DistributedSystem distSystem) {
     try {
-      DistributedSystem distSystem = InternalDistributedSystem.getAnyInstance();
       TransactionUtils.setLogWriter(distSystem.getLogWriter().convertToLogWriterI18n());
       cleanup();
       if (IGNORE_JTA) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/edabd633/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/GemFireCacheImplTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/GemFireCacheImplTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/GemFireCacheImplTest.java
new file mode 100644
index 0000000..1870c84
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/GemFireCacheImplTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import com.gemstone.gemfire.test.fake.Fakes;
+
+public class GemFireCacheImplTest {
+
+  @Test
+  public void test() {
+    
+    GemFireCacheImpl gfc = GemFireCacheImpl.createWithAsyncEventListeners(Fakes.distributedSystem(),
null);
+  }
+
+}


Mime
View raw message