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

jasonhuynh 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 604f2ad  GEODE-4476: Remove getInstance() calls from 
org.apache.geode.cache.query (#1427)
604f2ad is described below

commit 604f2ad6605575d79718534be2006d18e6a16026
Author: Jason Huynh <huyn...@gmail.com>
AuthorDate: Wed Feb 14 13:47:36 2018 -0800

    GEODE-4476: Remove getInstance() calls from org.apache.geode.cache.query 
(#1427)
    
      * Also removed test variables from product code
      * Tests will now set a property that allows tests to test query 
cancellation
---
 .../cache/query/internal/DefaultQueryService.java  | 16 ++++-----
 .../cache/query/internal/ExecutionContext.java     |  5 +--
 .../geode/cache/query/internal/QueryMonitor.java   | 37 +++++---------------
 .../cache/query/internal/index/AbstractIndex.java  | 10 +++---
 .../query/internal/index/AbstractMapIndex.java     | 13 +++----
 .../query/internal/index/CompactMapRangeIndex.java | 27 ++++++++-------
 .../query/internal/index/CompactRangeIndex.java    |  6 ++--
 .../cache/query/internal/index/HashIndex.java      | 17 +++++----
 .../cache/query/internal/index/IndexManager.java   | 40 +++++++++++++---------
 .../cache/query/internal/index/IndexUtils.java     |  5 +--
 .../cache/query/internal/index/MapRangeIndex.java  | 18 +++++-----
 .../query/internal/index/PartitionedIndex.java     | 11 +++---
 .../query/internal/index/PrimaryKeyIndex.java      |  7 ++--
 .../cache/query/internal/index/RangeIndex.java     | 11 +++---
 .../geode/internal/cache/EntryEventImpl.java       |  4 +--
 .../geode/internal/cache/GemFireCacheImpl.java     | 15 +++-----
 .../apache/geode/internal/cache/LocalRegion.java   |  2 +-
 .../geode/internal/cache/PartitionedRegion.java    | 14 ++++----
 .../internal/cache/control/HeapMemoryMonitor.java  |  5 ++-
 .../ResourceManagerWithQueryMonitorDUnitTest.java  | 22 ++++++++----
 .../index/DeclarativeIndexCreationJUnitTest.java   |  9 ++---
 .../index/IndexCreationInternalsJUnitTest.java     |  5 +--
 .../NewDeclarativeIndexCreationJUnitTest.java      | 15 ++++----
 .../internal/index/PartitionedIndexJUnitTest.java  |  7 ++--
 ...ProgRegionCreationIndexUpdateTypeJUnitTest.java | 16 ++++++---
 .../cache/query/dunit/QueryMonitorDUnitTest.java   | 18 ++--------
 26 files changed, 175 insertions(+), 180 deletions(-)

diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/DefaultQueryService.java
 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/DefaultQueryService.java
index 6ff058b..88f2ada 100644
--- 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/DefaultQueryService.java
+++ 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/DefaultQueryService.java
@@ -219,7 +219,7 @@ public class DefaultQueryService implements 
InternalQueryService {
 
     } else {
 
-      IndexManager indexManager = IndexUtils.getIndexManager(region, true);
+      IndexManager indexManager = IndexUtils.getIndexManager(this.cache, 
region, true);
       Index index = indexManager.createIndex(indexName, indexType, 
indexedExpression, fromClause,
           imports, null, null, loadEntries);
 
@@ -284,7 +284,7 @@ public class DefaultQueryService implements 
InternalQueryService {
     if (region == null) {
       return null;
     }
-    IndexManager indexManager = IndexUtils.getIndexManager(region, true);
+    IndexManager indexManager = IndexUtils.getIndexManager(cache, region, 
true);
     IndexData indexData = indexManager.getIndex(indexType, definitions, 
indexedExpression, context);
     return indexData;
   }
@@ -300,7 +300,7 @@ public class DefaultQueryService implements 
InternalQueryService {
     if (region instanceof PartitionedRegion) {
       return (Index) ((PartitionedRegion) region).getIndex().get(indexName);
     } else {
-      IndexManager indexManager = IndexUtils.getIndexManager(region, false);
+      IndexManager indexManager = IndexUtils.getIndexManager(cache, region, 
false);
       if (indexManager == null)
         return null;
       return indexManager.getIndex(indexName);
@@ -343,7 +343,7 @@ public class DefaultQueryService implements 
InternalQueryService {
     }
     // return getBestMatchIndex(region, indexType, definitions,
     // indexedExpression);
-    IndexManager indexManager = IndexUtils.getIndexManager(region, false);
+    IndexManager indexManager = IndexUtils.getIndexManager(cache, region, 
false);
     if (indexManager == null) {
       return null;
     }
@@ -378,7 +378,7 @@ public class DefaultQueryService implements 
InternalQueryService {
     if (region instanceof PartitionedRegion) {
       return ((PartitionedRegion) region).getIndexes();
     }
-    IndexManager indexManager = IndexUtils.getIndexManager(region, false);
+    IndexManager indexManager = IndexUtils.getIndexManager(cache, region, 
false);
     if (indexManager == null)
       return null;
     return indexManager.getIndexes();
@@ -391,7 +391,7 @@ public class DefaultQueryService implements 
InternalQueryService {
           "Index Operation is not supported on the Server Region.");
     }
 
-    IndexManager indexManager = IndexUtils.getIndexManager(region, false);
+    IndexManager indexManager = IndexUtils.getIndexManager(cache, region, 
false);
     if (indexManager == null)
       return null;
     return indexManager.getIndexes(indexType);
@@ -461,7 +461,7 @@ public class DefaultQueryService implements 
InternalQueryService {
             
.create(LocalizedStrings.DefaultQueryService_EXCEPTION_REMOVING_INDEX___0), ex);
       }
     }
-    IndexManager indexManager = IndexUtils.getIndexManager(region, false);
+    IndexManager indexManager = IndexUtils.getIndexManager(cache, region, 
false);
     if (indexManager == null)
       return;
 
@@ -937,7 +937,7 @@ public class DefaultQueryService implements 
InternalQueryService {
     }
     // Second step is iterating over REs and populating all the created
     // indexes
-    IndexManager indexManager = IndexUtils.getIndexManager(region, false);
+    IndexManager indexManager = IndexUtils.getIndexManager(cache, region, 
false);
     if (indexManager == null) {
       for (IndexCreationData icd : icds) {
         exceptionsMap.put(icd.getIndexName(),
diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/ExecutionContext.java
 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/ExecutionContext.java
index d186dea..717d78a 100644
--- 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/ExecutionContext.java
+++ 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/ExecutionContext.java
@@ -486,11 +486,12 @@ public class ExecutionContext {
         }
       }
       if (rgnPath != null) {
-        mgr = IndexUtils.getIndexManager(this.cache.getRegion(rgnPath), false);
+        mgr = IndexUtils.getIndexManager(this.cache, 
this.cache.getRegion(rgnPath), false);
         // put a check for null and see if we will be executing on a bucket 
region.
         if ((null == mgr) && (null != this.bukRgn)) {
           // for bucket region index use
-          mgr = 
IndexUtils.getIndexManager(this.cache.getRegion(this.bukRgn.getFullPath()), 
false);
+          mgr = IndexUtils.getIndexManager(this.cache,
+              this.cache.getRegion(this.bukRgn.getFullPath()), false);
         }
       }
     }
diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryMonitor.java
 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryMonitor.java
index 8a90ede..dd0653d 100755
--- 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryMonitor.java
+++ 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryMonitor.java
@@ -25,6 +25,7 @@ import org.apache.geode.cache.query.Query;
 import org.apache.geode.cache.query.QueryExecutionLowMemoryException;
 import org.apache.geode.cache.query.QueryExecutionTimeoutException;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.logging.log4j.LocalizedMessage;
@@ -44,6 +45,8 @@ import 
org.apache.geode.internal.logging.log4j.LocalizedMessage;
 public class QueryMonitor implements Runnable {
   private static final Logger logger = LogService.getLogger();
 
+  private final InternalCache cache;
+  private boolean testingQueryMonitor = false;
   /**
    * Holds the query execution status for the thread executing the query. 
FALSE if the query is not
    * canceled due to max query execution timeout. TRUE it the query is 
canceled due to max query
@@ -68,7 +71,8 @@ public class QueryMonitor implements Runnable {
 
   private static volatile long LOW_MEMORY_USED_BYTES = 0;
 
-  public QueryMonitor(long maxQueryExecutionTime) {
+  public QueryMonitor(InternalCache cache, long maxQueryExecutionTime) {
+    this.cache = cache;
     this.maxQueryExecutionTime = maxQueryExecutionTime;
   }
 
@@ -98,8 +102,7 @@ public class QueryMonitor implements Runnable {
     }
 
     // For dunit test purpose
-    if (GemFireCacheImpl.getInstance() != null
-        && GemFireCacheImpl.getInstance().testMaxQueryExecutionTime > 0) {
+    if (cache != null && testingQueryMonitor) {
       if (this.queryMonitorTasks == null) {
         this.queryMonitorTasks = new ConcurrentHashMap();
       }
@@ -119,29 +122,6 @@ public class QueryMonitor implements Runnable {
     synchronized (queryCompleted) {
       queryExecutionStatus.get().getAndSet(Boolean.FALSE);
 
-      // START - DUnit Test purpose.
-      if (GemFireCacheImpl.getInstance() != null
-          && GemFireCacheImpl.getInstance().testMaxQueryExecutionTime > 0) {
-        long maxTimeSet = 
GemFireCacheImpl.getInstance().testMaxQueryExecutionTime;
-        QueryThreadTask queryTask = (QueryThreadTask) queryThreads.peek();
-
-        long currentTime = System.currentTimeMillis();
-
-        // This is to check if the QueryMonitoring thread slept longer than 
the expected time.
-        // Its seen that in some cases based on OS thread scheduling the 
thread can sleep much
-        // longer than the specified time.
-        if (queryTask != null) {
-          if (currentTime - queryTask.StartTime > maxTimeSet) {
-            // The sleep() is unpredictable.
-            testException = new QueryExecutionTimeoutException(
-                "The QueryMonitor thread may be sleeping longer than"
-                    + " the set sleep time. This will happen as the sleep is 
based on OS thread scheduling,"
-                    + " verify the time spent by the executor thread.");
-          }
-        }
-      }
-      // END - DUnit Test purpose.
-
       defaultQuery.setQueryCompletedForMonitoring(true);
       // Remove the query task from the queue.
       queryThreads.remove(new QueryThreadTask(queryThread, null, null));
@@ -272,9 +252,8 @@ public class QueryMonitor implements Runnable {
     return LOW_MEMORY_USED_BYTES;
   }
 
-  public static void setLowMemory(boolean lowMemory, long usedBytes) {
-    if (GemFireCacheImpl.getInstance() != null
-        && 
!GemFireCacheImpl.getInstance().isQueryMonitorDisabledForLowMemory()) {
+  public void setLowMemory(boolean lowMemory, long usedBytes) {
+    if (cache != null && !cache.isQueryMonitorDisabledForLowMemory()) {
       QueryMonitor.LOW_MEMORY_USED_BYTES = usedBytes;
       QueryMonitor.LOW_MEMORY = lowMemory;
     }
diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractIndex.java
 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractIndex.java
index a025364..94ac8a8 100644
--- 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractIndex.java
+++ 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractIndex.java
@@ -94,6 +94,8 @@ public abstract class AbstractIndex implements IndexProtocol {
   static final AtomicIntegerFieldUpdater<RegionEntryToValuesMap> atomicUpdater 
=
       AtomicIntegerFieldUpdater.newUpdater(RegionEntryToValuesMap.class, 
"numValues");
 
+  final InternalCache cache;
+
   final String indexName;
 
   final Region region;
@@ -139,10 +141,10 @@ public abstract class AbstractIndex implements 
IndexProtocol {
   /** Flag to indicate if the index is populated with data */
   volatile boolean isPopulated = false;
 
-  AbstractIndex(String indexName, Region region, String fromClause, String 
indexedExpression,
-      String projectionAttributes, String originalFromClause, String 
originalIndexedExpression,
-      String[] defintions, IndexStatistics stats) {
-
+  AbstractIndex(InternalCache cache, String indexName, Region region, String 
fromClause,
+      String indexedExpression, String projectionAttributes, String 
originalFromClause,
+      String originalIndexedExpression, String[] defintions, IndexStatistics 
stats) {
+    this.cache = cache;
     this.indexName = indexName;
     this.region = region;
     this.indexedExpression = indexedExpression;
diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractMapIndex.java
 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractMapIndex.java
index d7d6351..40e1681 100644
--- 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractMapIndex.java
+++ 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractMapIndex.java
@@ -41,6 +41,7 @@ import org.apache.geode.cache.query.internal.MapIndexable;
 import org.apache.geode.cache.query.internal.RuntimeIterator;
 import org.apache.geode.cache.query.types.ObjectType;
 import org.apache.geode.internal.cache.BucketRegion;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.RegionEntry;
 
 public abstract class AbstractMapIndex extends AbstractIndex {
@@ -52,12 +53,12 @@ public abstract class AbstractMapIndex extends 
AbstractIndex {
 
   protected final Object[] mapKeys;
 
-  AbstractMapIndex(String indexName, Region region, String fromClause, String 
indexedExpression,
-      String projectionAttributes, String origFromClause, String origIndxExpr, 
String[] defintions,
-      boolean isAllKeys, String[] multiIndexingKeysPattern, Object[] mapKeys,
-      IndexStatistics stats) {
-    super(indexName, region, fromClause, indexedExpression, 
projectionAttributes, origFromClause,
-        origIndxExpr, defintions, stats);
+  AbstractMapIndex(InternalCache cache, String indexName, Region region, 
String fromClause,
+      String indexedExpression, String projectionAttributes, String 
origFromClause,
+      String origIndxExpr, String[] defintions, boolean isAllKeys,
+      String[] multiIndexingKeysPattern, Object[] mapKeys, IndexStatistics 
stats) {
+    super(cache, indexName, region, fromClause, indexedExpression, 
projectionAttributes,
+        origFromClause, origIndxExpr, defintions, stats);
     this.mapKeyToValueIndex = new ConcurrentHashMap<Object, AbstractIndex>(2, 
0.75f, 1);
     RegionAttributes ra = region.getAttributes();
     this.isAllKeys = isAllKeys;
diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactMapRangeIndex.java
 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactMapRangeIndex.java
index 43aeabc..1e15ae6 100644
--- 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactMapRangeIndex.java
+++ 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactMapRangeIndex.java
@@ -26,20 +26,21 @@ import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionAttributes;
 import org.apache.geode.cache.query.IndexStatistics;
 import org.apache.geode.cache.query.QueryService;
-import 
org.apache.geode.cache.query.internal.index.AbstractIndex.InternalIndexStatistics;
 import org.apache.geode.internal.cache.BucketRegion;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.RegionEntry;
 
 public class CompactMapRangeIndex extends AbstractMapIndex {
   private final Map<Object, Map> entryToMapKeyIndexKeyMap;
   private IndexCreationHelper ich;
 
-  CompactMapRangeIndex(String indexName, Region region, String fromClause, 
String indexedExpression,
-      String projectionAttributes, String origFromClause, String origIndxExpr, 
String[] defintions,
-      boolean isAllKeys, String[] multiIndexingKeysPattern, Object[] mapKeys,
-      IndexStatistics stats) {
-    super(indexName, region, fromClause, indexedExpression, 
projectionAttributes, origFromClause,
-        origIndxExpr, defintions, isAllKeys, multiIndexingKeysPattern, 
mapKeys, stats);
+  CompactMapRangeIndex(InternalCache cache, String indexName, Region region, 
String fromClause,
+      String indexedExpression, String projectionAttributes, String 
origFromClause,
+      String origIndxExpr, String[] defintions, boolean isAllKeys,
+      String[] multiIndexingKeysPattern, Object[] mapKeys, IndexStatistics 
stats) {
+    super(cache, indexName, region, fromClause, indexedExpression, 
projectionAttributes,
+        origFromClause, origIndxExpr, defintions, isAllKeys, 
multiIndexingKeysPattern, mapKeys,
+        stats);
     RegionAttributes ra = region.getAttributes();
     this.entryToMapKeyIndexKeyMap = new java.util.concurrent.ConcurrentHashMap(
         ra.getInitialCapacity(), ra.getLoadFactor(), ra.getConcurrencyLevel());
@@ -159,9 +160,9 @@ public class CompactMapRangeIndex extends AbstractMapIndex {
         prIndex = (PartitionedIndex) this.getPRIndex();
         prIndex.incNumMapKeysStats(mapKey);
       }
-      rg = new CompactRangeIndex(indexName + "-" + mapKey, region, fromClause, 
indexedExpression,
-          projectionAttributes, this.originalFromClause, 
this.originalIndexedExpression,
-          this.canonicalizedDefinitions, stats);
+      rg = new CompactRangeIndex(cache, indexName + "-" + mapKey, region, 
fromClause,
+          indexedExpression, projectionAttributes, this.originalFromClause,
+          this.originalIndexedExpression, this.canonicalizedDefinitions, 
stats);
       rg.instantiateEvaluator(this.ich,
           ((AbstractIndex.IMQEvaluator) 
this.evaluator).getIndexResultSetType());
       this.mapKeyToValueIndex.put(mapKey, rg);
@@ -206,9 +207,9 @@ public class CompactMapRangeIndex extends AbstractMapIndex {
         prIndex = (PartitionedIndex) this.getPRIndex();
         prIndex.incNumMapKeysStats(mapKey);
       }
-      rg = new CompactRangeIndex(indexName + "-" + mapKey, region, fromClause, 
indexedExpression,
-          projectionAttributes, this.originalFromClause, 
this.originalIndexedExpression,
-          this.canonicalizedDefinitions, stats);
+      rg = new CompactRangeIndex(cache, indexName + "-" + mapKey, region, 
fromClause,
+          indexedExpression, projectionAttributes, this.originalFromClause,
+          this.originalIndexedExpression, this.canonicalizedDefinitions, 
stats);
       rg.instantiateEvaluator(this.ich,
           ((AbstractIndex.IMQEvaluator) 
this.evaluator).getIndexResultSetType());
       this.mapKeyToValueIndex.put(mapKey, rg);
diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactRangeIndex.java
 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactRangeIndex.java
index 054e8b0..2c8c935 100644
--- 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactRangeIndex.java
+++ 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactRangeIndex.java
@@ -95,11 +95,11 @@ public class CompactRangeIndex extends AbstractIndex {
 
   static boolean TEST_ALWAYS_UPDATE_IN_PROGRESS = false;
 
-  public CompactRangeIndex(String indexName, Region region, String fromClause,
+  public CompactRangeIndex(InternalCache cache, String indexName, Region 
region, String fromClause,
       String indexedExpression, String projectionAttributes, String 
origFromClause,
       String origIndexExpr, String[] definitions, IndexStatistics stats) {
-    super(indexName, region, fromClause, indexedExpression, 
projectionAttributes, origFromClause,
-        origIndexExpr, definitions, stats);
+    super(cache, indexName, region, fromClause, indexedExpression, 
projectionAttributes,
+        origFromClause, origIndexExpr, definitions, stats);
     if (IndexManager.IS_TEST_LDM) {
       indexStore = new MapIndexStore(
           ((LocalRegion) region).getIndexMap(indexName, indexedExpression, 
origFromClause), region);
diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/HashIndex.java
 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/HashIndex.java
index c0fc0aa..0f43a6d 100755
--- 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/HashIndex.java
+++ 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/HashIndex.java
@@ -14,7 +14,7 @@
  */
 package org.apache.geode.cache.query.internal.index;
 
-import static org.apache.geode.internal.lang.SystemUtils.*;
+import static org.apache.geode.internal.lang.SystemUtils.getLineSeparator;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -67,7 +67,6 @@ import 
org.apache.geode.cache.query.internal.types.StructTypeImpl;
 import org.apache.geode.cache.query.internal.types.TypeUtils;
 import org.apache.geode.cache.query.types.ObjectType;
 import org.apache.geode.internal.cache.CachedDeserializable;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.LocalRegion;
 import org.apache.geode.internal.cache.RegionEntry;
@@ -131,11 +130,11 @@ public class HashIndex extends AbstractIndex {
    * @param projectionAttributes not used
    * @param definitions the canonicalized definitions
    */
-  public HashIndex(String indexName, Region region, String fromClause, String 
indexedExpression,
-      String projectionAttributes, String origFromClause, String origIndexExpr,
-      String[] definitions, IndexStatistics stats) {
-    super(indexName, region, fromClause, indexedExpression, 
projectionAttributes, origFromClause,
-        origIndexExpr, definitions, stats);
+  public HashIndex(InternalCache cache, String indexName, Region region, 
String fromClause,
+      String indexedExpression, String projectionAttributes, String 
origFromClause,
+      String origIndexExpr, String[] definitions, IndexStatistics stats) {
+    super(cache, indexName, region, fromClause, indexedExpression, 
projectionAttributes,
+        origFromClause, origIndexExpr, definitions, stats);
     RegionAttributes ra = region.getAttributes();
 
 
@@ -522,7 +521,7 @@ public class HashIndex extends AbstractIndex {
     }
 
     try {
-      long iteratorCreationTime = 
GemFireCacheImpl.getInstance().cacheTimeMillis();
+      long iteratorCreationTime = cache.cacheTimeMillis();
 
       switch (operator) {
         case OQLLexerTokenTypes.TOK_EQ:
@@ -549,7 +548,7 @@ public class HashIndex extends AbstractIndex {
       } else if (operator == OQLLexerTokenTypes.TOK_NE
           || operator == OQLLexerTokenTypes.TOK_NE_ALT) { // put
         keysToRemove.add(key);
-        long iteratorCreationTime = 
GemFireCacheImpl.getInstance().cacheTimeMillis();
+        long iteratorCreationTime = cache.cacheTimeMillis();
         
addToResultsFromEntries(this.entriesSet.getAllNotMatching(keysToRemove), 
results, iterOps,
             runtimeItr, context, projAttrib, intermediateResults, 
isIntersection,
             multiColOrderBy ? -1 : limit, keysToRemove, applyOrderBy, asc, 
iteratorCreationTime);
diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/IndexManager.java
 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/IndexManager.java
index 1958fd1..104bfcb 100644
--- 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/IndexManager.java
+++ 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/IndexManager.java
@@ -85,6 +85,7 @@ public class IndexManager {
   // Asif : This action is to rerun Index creation after
   // clear is called on the region
   public static final int RECREATE_INDEX = 4;
+  private final InternalCache cache;
   protected final Region region;
 
   private final boolean isOverFlowToDisk;
@@ -155,7 +156,8 @@ public class IndexManager {
   // @todo ericz
   // there should be a read/write lock PER INDEX in order to maximize
   // the concurrency of query execution.
-  public IndexManager(Region region) {
+  public IndexManager(InternalCache cache, Region region) {
+    this.cache = cache;
     this.region = region;
     // must be a SortedMap to ensure the indexes are iterated over in fixed
     // order
@@ -360,7 +362,7 @@ public class IndexManager {
         }
       }
 
-      IndexTask indexTask = new IndexTask(indexName, indexType, origFromClause,
+      IndexTask indexTask = new IndexTask(cache, indexName, indexType, 
origFromClause,
           origIndexedExpression, helper, isCompactOrHash, prIndex, 
loadEntries);
       FutureTask<Index> indexFutureTask = new FutureTask<Index>(indexTask);
       Object oldIndex = this.indexes.putIfAbsent(indexTask, indexFutureTask);
@@ -499,7 +501,7 @@ public class IndexManager {
   }
 
   public Index getIndex(String indexName) {
-    IndexTask indexTask = new IndexTask(indexName);
+    IndexTask indexTask = new IndexTask(cache, indexName);
     Object ind = this.indexes.get(indexTask);
     // Check if the returned value is instance of Index (this means
     // the index is not in create phase, its created successfully).
@@ -510,7 +512,7 @@ public class IndexManager {
   }
 
   public void addIndex(String indexName, Index index) {
-    IndexTask indexTask = new IndexTask(indexName);
+    IndexTask indexTask = new IndexTask(cache, indexName);
     this.indexes.put(indexTask, index);
   }
 
@@ -836,7 +838,7 @@ public class IndexManager {
     // is OK as we are not clearing data maps . The destroy though marks
     // the index invalid , that is OK. Because of this flag a query
     // may or may not use the Index
-    IndexTask indexTask = new IndexTask(index.getName());
+    IndexTask indexTask = new IndexTask(cache, index.getName());
     if (this.indexes.remove(indexTask) != null) {
       AbstractIndex indexHandle = (AbstractIndex) index;
       indexHandle.destroy();
@@ -1536,9 +1538,12 @@ public class IndexManager {
 
     public boolean loadEntries;
 
-    IndexTask(String indexName, IndexType type, String origFromClause, String 
origIndexedExpression,
-        IndexCreationHelper helper, boolean isCompactOrHash, PartitionedIndex 
prIndex,
-        boolean loadEntries) {
+    private final InternalCache cache;
+
+    IndexTask(InternalCache cache, String indexName, IndexType type, String 
origFromClause,
+        String origIndexedExpression, IndexCreationHelper helper, boolean 
isCompactOrHash,
+        PartitionedIndex prIndex, boolean loadEntries) {
+      this.cache = cache;
       this.indexName = indexName;
       this.indexType = type;
       this.origFromClause = origFromClause;
@@ -1550,7 +1555,8 @@ public class IndexManager {
     }
 
     /* For name based index search */
-    IndexTask(String indexName) {
+    IndexTask(InternalCache cache, String indexName) {
+      this.cache = cache;
       this.indexName = indexName;
     }
 
@@ -1607,12 +1613,12 @@ public class IndexManager {
         stats = this.prIndex.getStatistics();
       }
       if (indexType == IndexType.PRIMARY_KEY) {
-        index = new PrimaryKeyIndex(indexName, region, fromClause, 
indexedExpression,
+        index = new PrimaryKeyIndex(cache, indexName, region, fromClause, 
indexedExpression,
             projectionAttributes, origFromClause, origIndexedExpression, 
definitions, stats);
         logger.info("Using Primary Key index implementation for '{}' on region 
{}", indexName,
             region.getFullPath());
       } else if (indexType == IndexType.HASH) {
-        index = new HashIndex(indexName, region, fromClause, indexedExpression,
+        index = new HashIndex(cache, indexName, region, fromClause, 
indexedExpression,
             projectionAttributes, origFromClause, origIndexedExpression, 
definitions, stats);
 
         logger.info("Using Hash index implementation for '{}' on region {}", 
indexName,
@@ -1622,28 +1628,28 @@ public class IndexManager {
         // shouldCreateCompactIndex((FunctionalIndexCreationHelper)helper);
         if (this.isCompactOrHash || this.isLDM) {
           if (indexType == IndexType.FUNCTIONAL && !helper.isMapTypeIndex()) {
-            index = new CompactRangeIndex(indexName, region, fromClause, 
indexedExpression,
+            index = new CompactRangeIndex(cache, indexName, region, 
fromClause, indexedExpression,
                 projectionAttributes, origFromClause, origIndexedExpression, 
definitions, stats);
             logger.info("Using Compact Range index implementation for '{}' on 
region {}", indexName,
                 region.getFullPath());
           } else {
             FunctionalIndexCreationHelper fich = 
(FunctionalIndexCreationHelper) helper;
-            index = new CompactMapRangeIndex(indexName, region, fromClause, 
indexedExpression,
-                projectionAttributes, origFromClause, origIndexedExpression, 
definitions,
-                fich.isAllKeys(), fich.multiIndexKeysPattern, fich.mapKeys, 
stats);
+            index = new CompactMapRangeIndex(cache, indexName, region, 
fromClause,
+                indexedExpression, projectionAttributes, origFromClause, 
origIndexedExpression,
+                definitions, fich.isAllKeys(), fich.multiIndexKeysPattern, 
fich.mapKeys, stats);
             logger.info("Using Compact Map Range index implementation for '{}' 
on region {}",
                 indexName, region.getFullPath());
           }
         } else {
           assert indexType == IndexType.FUNCTIONAL;
           if (!helper.isMapTypeIndex()) {
-            index = new RangeIndex(indexName, region, fromClause, 
indexedExpression,
+            index = new RangeIndex(cache, indexName, region, fromClause, 
indexedExpression,
                 projectionAttributes, origFromClause, origIndexedExpression, 
definitions, stats);
             logger.info("Using Non-Compact index implementation for '{}' on 
region {}", indexName,
                 region.getFullPath());
           } else {
             FunctionalIndexCreationHelper fich = 
(FunctionalIndexCreationHelper) helper;
-            index = new MapRangeIndex(indexName, region, fromClause, 
indexedExpression,
+            index = new MapRangeIndex(cache, indexName, region, fromClause, 
indexedExpression,
                 projectionAttributes, origFromClause, origIndexedExpression, 
definitions,
                 fich.isAllKeys(), fich.multiIndexKeysPattern, fich.mapKeys, 
stats);
             logger.info("Using Non-Compact Map index implementation for '{}' 
on region {}",
diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/IndexUtils.java
 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/IndexUtils.java
index 3bd41e0..368e0d7 100644
--- 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/IndexUtils.java
+++ 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/IndexUtils.java
@@ -39,7 +39,8 @@ public class IndexUtils {
     IndexUtils.testHook = testHook;
   }
 
-  public static IndexManager getIndexManager(Region region, boolean 
createIfNotAvailable) {
+  public static IndexManager getIndexManager(InternalCache cache, Region 
region,
+      boolean createIfNotAvailable) {
     if (region == null || region.isDestroyed()) {
       return null;
     }
@@ -55,7 +56,7 @@ public class IndexUtils {
       synchronized (imSync) {
         // Double checked locking
         if (lRegion.getIndexManager() == null) {
-          idxMgr = new IndexManager(region);
+          idxMgr = new IndexManager(cache, region);
           lRegion.setIndexManager(idxMgr);
         } else {
           idxMgr = lRegion.getIndexManager();
diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/MapRangeIndex.java
 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/MapRangeIndex.java
index 2ec8ff4..4e42145 100644
--- 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/MapRangeIndex.java
+++ 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/MapRangeIndex.java
@@ -21,17 +21,19 @@ import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionAttributes;
 import org.apache.geode.cache.query.IndexStatistics;
 import org.apache.geode.internal.cache.BucketRegion;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.RegionEntry;
 
 public class MapRangeIndex extends AbstractMapIndex {
   protected final RegionEntryToValuesMap entryToMapKeysMap;
 
-  MapRangeIndex(String indexName, Region region, String fromClause, String 
indexedExpression,
-      String projectionAttributes, String origFromClause, String origIndxExpr, 
String[] defintions,
-      boolean isAllKeys, String[] multiIndexingKeysPattern, Object[] mapKeys,
-      IndexStatistics stats) {
-    super(indexName, region, fromClause, indexedExpression, 
projectionAttributes, origFromClause,
-        origIndxExpr, defintions, isAllKeys, multiIndexingKeysPattern, 
mapKeys, stats);
+  MapRangeIndex(InternalCache cache, String indexName, Region region, String 
fromClause,
+      String indexedExpression, String projectionAttributes, String 
origFromClause,
+      String origIndxExpr, String[] defintions, boolean isAllKeys,
+      String[] multiIndexingKeysPattern, Object[] mapKeys, IndexStatistics 
stats) {
+    super(cache, indexName, region, fromClause, indexedExpression, 
projectionAttributes,
+        origFromClause, origIndxExpr, defintions, isAllKeys, 
multiIndexingKeysPattern, mapKeys,
+        stats);
     RegionAttributes ra = region.getAttributes();
     this.entryToMapKeysMap =
         new RegionEntryToValuesMap(
@@ -132,7 +134,7 @@ public class MapRangeIndex extends AbstractMapIndex {
         prIndex = (PartitionedIndex) this.getPRIndex();
         prIndex.incNumMapKeysStats(mapKey);
       }
-      rg = new RangeIndex(indexName + "-" + mapKey, region, fromClause, 
indexedExpression,
+      rg = new RangeIndex(cache, indexName + "-" + mapKey, region, fromClause, 
indexedExpression,
           projectionAttributes, this.originalFromClause, 
this.originalIndexedExpression,
           this.canonicalizedDefinitions, stats);
       // Shobhit: We need evaluator to verify RegionEntry and IndexEntry 
inconsistency.
@@ -166,7 +168,7 @@ public class MapRangeIndex extends AbstractMapIndex {
         prIndex = (PartitionedIndex) this.getPRIndex();
         prIndex.incNumMapKeysStats(mapKey);
       }
-      rg = new RangeIndex(indexName + "-" + mapKey, region, fromClause, 
indexedExpression,
+      rg = new RangeIndex(cache, indexName + "-" + mapKey, region, fromClause, 
indexedExpression,
           projectionAttributes, this.originalFromClause, 
this.originalIndexedExpression,
           this.canonicalizedDefinitions, stats);
       rg.evaluator = this.evaluator;
diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/PartitionedIndex.java
 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/PartitionedIndex.java
index 25765ff..c556dc7 100755
--- 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/PartitionedIndex.java
+++ 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/PartitionedIndex.java
@@ -39,6 +39,7 @@ import org.apache.geode.cache.query.internal.ExecutionContext;
 import org.apache.geode.cache.query.internal.RuntimeIterator;
 import org.apache.geode.cache.query.types.ObjectType;
 import org.apache.geode.internal.cache.BucketRegion;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.PartitionedRegion;
 import org.apache.geode.internal.cache.PartitionedRegionDataStore;
 import org.apache.geode.internal.cache.RegionEntry;
@@ -87,10 +88,10 @@ public class PartitionedIndex extends AbstractIndex {
    * Constructor for partitioned indexed. Creates the partitioned index on 
given a partitioned
    * region. An index can be created programmatically or through cache.xml 
during initialization.
    */
-  public PartitionedIndex(IndexType iType, String indexName, Region r, String 
indexedExpression,
-      String fromClause, String imports) {
-    super(indexName, r, fromClause, indexedExpression, null, fromClause, 
indexedExpression, null,
-        null);
+  public PartitionedIndex(InternalCache cache, IndexType iType, String 
indexName, Region r,
+      String indexedExpression, String fromClause, String imports) {
+    super(cache, indexName, r, fromClause, indexedExpression, null, 
fromClause, indexedExpression,
+        null, null);
     this.type = iType;
     this.imports = imports;
 
@@ -251,7 +252,7 @@ public class PartitionedIndex extends AbstractIndex {
       if (bukRegion == null) {
         throw new QueryInvocationTargetException("Bucket not found for the id 
:" + bId);
       }
-      IndexManager im = IndexUtils.getIndexManager(bukRegion, true);
+      IndexManager im = IndexUtils.getIndexManager(cache, bukRegion, true);
       if (im != null && im.getIndex(indexName) == null) {
         try {
           if (pr.getCache().getLogger().fineEnabled()) {
diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/PrimaryKeyIndex.java
 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/PrimaryKeyIndex.java
index 0a066e4..af80e48 100644
--- 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/PrimaryKeyIndex.java
+++ 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/PrimaryKeyIndex.java
@@ -41,6 +41,7 @@ import org.apache.geode.cache.query.internal.Support;
 import org.apache.geode.cache.query.internal.parse.OQLLexerTokenTypes;
 import org.apache.geode.cache.query.internal.types.ObjectTypeImpl;
 import org.apache.geode.cache.query.types.ObjectType;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.LocalRegion;
 import org.apache.geode.internal.cache.RegionEntry;
 import org.apache.geode.internal.i18n.LocalizedStrings;
@@ -51,11 +52,11 @@ public class PrimaryKeyIndex extends AbstractIndex {
   protected long numUses = 0;
   ObjectType indexResultType;
 
-  public PrimaryKeyIndex(String indexName, Region region, String fromClause,
+  public PrimaryKeyIndex(InternalCache cache, String indexName, Region region, 
String fromClause,
       String indexedExpression, String projectionAttributes, String 
origFromClause,
       String origIndxExpr, String[] defintions, IndexStatistics 
indexStatistics) {
-    super(indexName, region, fromClause, indexedExpression, 
projectionAttributes, origFromClause,
-        origIndxExpr, defintions, indexStatistics);
+    super(cache, indexName, region, fromClause, indexedExpression, 
projectionAttributes,
+        origFromClause, origIndxExpr, defintions, indexStatistics);
     // TODO: Check if the below is correct
     Class constr = region.getAttributes().getValueConstraint();
     if (constr == null)
diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/RangeIndex.java
 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/RangeIndex.java
index 1458b74..042c616 100644
--- 
a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/RangeIndex.java
+++ 
b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/RangeIndex.java
@@ -51,6 +51,7 @@ import 
org.apache.geode.cache.query.internal.index.IndexStore.IndexStoreEntry;
 import org.apache.geode.cache.query.internal.parse.OQLLexerTokenTypes;
 import org.apache.geode.cache.query.internal.types.TypeUtils;
 import org.apache.geode.cache.query.types.ObjectType;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.RegionEntry;
 import org.apache.geode.internal.cache.persistence.query.CloseableIterator;
 import org.apache.geode.internal.i18n.LocalizedStrings;
@@ -95,11 +96,11 @@ public class RangeIndex extends AbstractIndex {
    * @param projectionAttributes expression that transforms each element in 
the result set of a
    *        query Return the newly created Index
    */
-  public RangeIndex(String indexName, Region region, String fromClause, String 
indexedExpression,
-      String projectionAttributes, String origFromClause, String origIndexExpr,
-      String[] definitions, IndexStatistics stats) {
-    super(indexName, region, fromClause, indexedExpression, 
projectionAttributes, origFromClause,
-        origIndexExpr, definitions, stats);
+  public RangeIndex(InternalCache cache, String indexName, Region region, 
String fromClause,
+      String indexedExpression, String projectionAttributes, String 
origFromClause,
+      String origIndexExpr, String[] definitions, IndexStatistics stats) {
+    super(cache, indexName, region, fromClause, indexedExpression, 
projectionAttributes,
+        origFromClause, origIndexExpr, definitions, stats);
 
     RegionAttributes ra = region.getAttributes();
     this.entryToValuesMap = new RegionEntryToValuesMap(
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java 
b/geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java
index 73cd10a..7ee03a8 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java
@@ -33,7 +33,6 @@ import org.apache.geode.GemFireIOException;
 import org.apache.geode.InvalidDeltaException;
 import org.apache.geode.SerializationException;
 import org.apache.geode.SystemFailure;
-import org.apache.geode.cache.EntryEvent;
 import org.apache.geode.cache.EntryNotFoundException;
 import org.apache.geode.cache.EntryOperation;
 import org.apache.geode.cache.Operation;
@@ -1676,7 +1675,8 @@ public class EntryEventImpl implements 
InternalEntryEvent, InternalCacheEvent,
       // indexed.
 
       if ((this.op.isUpdate() && !reentry.isInvalid()) || 
this.op.isInvalidate()) {
-        IndexManager idxManager = IndexUtils.getIndexManager(this.region, 
false);
+        IndexManager idxManager =
+            IndexUtils.getIndexManager(this.region.getCache(), this.region, 
false);
         if (idxManager != null) {
           try {
             idxManager.updateIndexes(reentry, IndexManager.REMOVE_ENTRY,
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 1549cd9..594dbdf 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
@@ -307,7 +307,7 @@ public class GemFireCacheImpl implements InternalCache, 
InternalClientCache, Has
    * System property to limit the max query-execution time. By default its 
turned off (-1), the time
    * is set in milliseconds.
    */
-  public static final int MAX_QUERY_EXECUTION_TIME =
+  public static int MAX_QUERY_EXECUTION_TIME =
       Integer.getInteger(DistributionConfig.GEMFIRE_PREFIX + 
"Cache.MAX_QUERY_EXECUTION_TIME", -1);
 
   /**
@@ -328,9 +328,6 @@ public class GemFireCacheImpl implements InternalCache, 
InternalClientCache, Has
 
   private volatile ConfigurationResponse configurationResponse;
 
-  /** To test MAX_QUERY_EXECUTION_TIME option. */
-  public int testMaxQueryExecutionTime = -1;
-
   private final InternalDistributedSystem system;
 
   private final DistributionManager dm;
@@ -4478,7 +4475,7 @@ public class GemFireCacheImpl implements InternalCache, 
InternalClientCache, Has
     boolean monitorRequired =
         !this.queryMonitorDisabledForLowMem && 
queryMonitorRequiredForResourceManager;
     // Added for DUnit test purpose, which turns-on and off the 
this.testMaxQueryExecutionTime.
-    if (!(MAX_QUERY_EXECUTION_TIME > 0 || this.testMaxQueryExecutionTime > 0 
|| monitorRequired)) {
+    if (!(MAX_QUERY_EXECUTION_TIME > 0 || monitorRequired)) {
       // if this.testMaxQueryExecutionTime is set, send the QueryMonitor.
       // Else send null, so that the QueryMonitor is turned-off.
       return null;
@@ -4486,13 +4483,11 @@ public class GemFireCacheImpl implements InternalCache, 
InternalClientCache, Has
 
     // Return the QueryMonitor service if MAX_QUERY_EXECUTION_TIME is set or 
it is required by the
     // ResourceManager and not overridden by system property.
-    boolean needQueryMonitor =
-        MAX_QUERY_EXECUTION_TIME > 0 || this.testMaxQueryExecutionTime > 0 || 
monitorRequired;
+    boolean needQueryMonitor = MAX_QUERY_EXECUTION_TIME > 0 || monitorRequired;
     if (needQueryMonitor && this.queryMonitor == null) {
       synchronized (this.queryMonitorLock) {
         if (this.queryMonitor == null) {
-          int maxTime = MAX_QUERY_EXECUTION_TIME > 
this.testMaxQueryExecutionTime
-              ? MAX_QUERY_EXECUTION_TIME : this.testMaxQueryExecutionTime;
+          int maxTime = MAX_QUERY_EXECUTION_TIME;
 
           if (monitorRequired && maxTime < 0) {
             // this means that the resource manager is being used and we need 
to monitor query
@@ -4501,7 +4496,7 @@ public class GemFireCacheImpl implements InternalCache, 
InternalClientCache, Has
             maxTime = FIVE_HOURS;
           }
 
-          this.queryMonitor = new QueryMonitor(maxTime);
+          this.queryMonitor = new QueryMonitor(this, maxTime);
           final LoggingThreadGroup group =
               LoggingThreadGroup.createThreadGroup("QueryMonitor Thread 
Group", logger);
           Thread qmThread = new Thread(group, this.queryMonitor, "QueryMonitor 
Thread");
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 c33a13a..bfeae68 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
@@ -2373,7 +2373,7 @@ public class LocalRegion extends AbstractRegion 
implements LoaderHelperFactory,
     List oqlIndexes = internalRegionArgs.getIndexes();
 
     if (this.indexManager == null) {
-      this.indexManager = IndexUtils.getIndexManager(this, true);
+      this.indexManager = IndexUtils.getIndexManager(cache, this, true);
     }
     DiskRegion dr = this.getDiskRegion();
     boolean isOverflowToDisk = false;
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
index 98f4cf5..d3b0f48 100755
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
@@ -8259,7 +8259,7 @@ public class PartitionedRegion extends LocalRegion
 
     // Create indexManager.
     if (this.indexManager == null) {
-      this.indexManager = IndexUtils.getIndexManager(this, true);
+      this.indexManager = IndexUtils.getIndexManager(cache, this, true);
     }
 
     if (logger.isDebugEnabled()) {
@@ -8496,7 +8496,7 @@ public class PartitionedRegion extends LocalRegion
         if (bucket == null) {
           continue;
         }
-        IndexManager bucketIndexManager = IndexUtils.getIndexManager(bucket, 
true);
+        IndexManager bucketIndexManager = IndexUtils.getIndexManager(cache, 
bucket, true);
         Set<Index> bucketIndexes = getBucketIndexesForPRIndexes(bucket, 
indexes);
         try {
           bucketIndexManager.populateIndexes(bucketIndexes);
@@ -8653,7 +8653,7 @@ public class PartitionedRegion extends LocalRegion
         bucket = (LocalRegion) bucketEntry.getValue();
         if (bucket != null) {
           bucket.waitForData();
-          IndexManager indexMang = IndexUtils.getIndexManager(bucket, false);
+          IndexManager indexMang = IndexUtils.getIndexManager(cache, bucket, 
false);
           if (indexMang != null) {
             indexMang.removeIndexes();
             numBuckets++;
@@ -9568,7 +9568,7 @@ public class PartitionedRegion extends LocalRegion
         logger.info(LocalizedMessage.create(
             
LocalizedStrings.PartitionedRegion_THIS_IS_AN_ACCESSOR_VM_AND_DOESNT_CONTAIN_DATA));
 
-        prIndex = new PartitionedIndex(indexType, indexName, 
PartitionedRegion.this,
+        prIndex = new PartitionedIndex(cache, indexType, indexName, 
PartitionedRegion.this,
             indexedExpression, fromClause, imports);
       }
 
@@ -9590,8 +9590,8 @@ public class PartitionedRegion extends LocalRegion
       }
 
       // imports can be null
-      PartitionedIndex parIndex = new PartitionedIndex(indexType, indexName, 
PartitionedRegion.this,
-          indexedExpression, fromClause, imports);
+      PartitionedIndex parIndex = new PartitionedIndex(cache, indexType, 
indexName,
+          PartitionedRegion.this, indexedExpression, fromClause, imports);
 
       // In cases where we have no data yet (creation from cache xml), it 
would leave the populated
       // flag to false Not really an issue as a put will trigger bucket index 
creation which should
@@ -9611,7 +9611,7 @@ public class PartitionedRegion extends LocalRegion
 
         ExecutionContext externalContext = new ExecutionContext(null, cache);
         externalContext.setBucketRegion(PartitionedRegion.this, (BucketRegion) 
bucket);
-        IndexManager indMng = IndexUtils.getIndexManager(bucket, true);
+        IndexManager indMng = IndexUtils.getIndexManager(cache, bucket, true);
         try {
           Index bucketIndex = indMng.createIndex(indexName, indexType, 
indexedExpression,
               fromClause, imports, externalContext, parIndex, loadEntries);
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/control/HeapMemoryMonitor.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/control/HeapMemoryMonitor.java
index c3c4c8d..f187f2e 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/control/HeapMemoryMonitor.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/control/HeapMemoryMonitor.java
@@ -36,7 +36,6 @@ import org.apache.logging.log4j.Logger;
 import org.apache.geode.CancelException;
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.CacheClosedException;
-import org.apache.geode.cache.query.internal.QueryMonitor;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import 
org.apache.geode.distributed.internal.membership.InternalDistributedMember;
 import org.apache.geode.internal.SetUtils;
@@ -661,7 +660,7 @@ public class HeapMemoryMonitor implements 
NotificationListener, MemoryMonitor {
           LocalizedStrings.MemoryMonitor_MEMBER_ABOVE_CRITICAL_THRESHOLD,
           new Object[] {event.getMember(), "heap"});
       if (!this.cache.isQueryMonitorDisabledForLowMemory()) {
-        QueryMonitor.setLowMemory(true, event.getBytesUsed());
+        this.cache.getQueryMonitor().setLowMemory(true, event.getBytesUsed());
         this.cache.getQueryMonitor().cancelAllQueriesDueToMemory();
       }
 
@@ -670,7 +669,7 @@ public class HeapMemoryMonitor implements 
NotificationListener, MemoryMonitor {
           LocalizedStrings.MemoryMonitor_MEMBER_BELOW_CRITICAL_THRESHOLD,
           new Object[] {event.getMember(), "heap"});
       if (!this.cache.isQueryMonitorDisabledForLowMemory()) {
-        QueryMonitor.setLowMemory(false, event.getBytesUsed());
+        this.cache.getQueryMonitor().setLowMemory(false, event.getBytesUsed());
       }
     }
 
diff --git 
a/geode-core/src/test/java/org/apache/geode/cache/query/dunit/ResourceManagerWithQueryMonitorDUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/cache/query/dunit/ResourceManagerWithQueryMonitorDUnitTest.java
index 15b606f..452338c 100755
--- 
a/geode-core/src/test/java/org/apache/geode/cache/query/dunit/ResourceManagerWithQueryMonitorDUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/cache/query/dunit/ResourceManagerWithQueryMonitorDUnitTest.java
@@ -14,8 +14,13 @@
  */
 package org.apache.geode.cache.query.dunit;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.apache.geode.test.dunit.Assert.*;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.apache.geode.test.dunit.Assert.assertEquals;
+import static org.apache.geode.test.dunit.Assert.assertFalse;
+import static org.apache.geode.test.dunit.Assert.assertNotNull;
+import static org.apache.geode.test.dunit.Assert.assertTrue;
+import static org.apache.geode.test.dunit.Assert.fail;
 
 import java.util.Iterator;
 import java.util.Properties;
@@ -51,7 +56,6 @@ import org.apache.geode.cache.query.SelectResults;
 import org.apache.geode.cache.query.TypeMismatchException;
 import org.apache.geode.cache.query.data.Portfolio;
 import org.apache.geode.cache.query.internal.DefaultQuery;
-import org.apache.geode.cache.query.internal.QueryMonitor;
 import org.apache.geode.cache.server.CacheServer;
 import org.apache.geode.cache30.CacheSerializableRunnable;
 import org.apache.geode.cache30.ClientServerTestCase;
@@ -59,6 +63,7 @@ import 
org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.internal.cache.DistributedRegion;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.PartitionedRegion;
 import org.apache.geode.internal.cache.control.HeapMemoryMonitor;
 import org.apache.geode.internal.cache.control.InternalResourceManager;
@@ -129,7 +134,10 @@ public class ResourceManagerWithQueryMonitorDUnitTest 
extends ClientServerTestCa
 
   private SerializableCallable resetQueryMonitor = new SerializableCallable() {
     public Object call() throws Exception {
-      QueryMonitor.setLowMemory(false, 0);
+      InternalCache cache = getCache();
+      if (cache.getQueryMonitor() != null) {
+        cache.getQueryMonitor().setLowMemory(false, 0);
+      }
       DefaultQuery.testHook = null;
       return null;
     }
@@ -946,7 +954,7 @@ public class ResourceManagerWithQueryMonitorDUnitTest 
extends ClientServerTestCa
     server.invoke(new SerializableCallable() {
       public Object call() throws Exception {
         GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
-        cache.testMaxQueryExecutionTime = -1;
+        cache.MAX_QUERY_EXECUTION_TIME = -1;
         return null;
       }
     });
@@ -971,9 +979,9 @@ public class ResourceManagerWithQueryMonitorDUnitTest 
extends ClientServerTestCa
         GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
 
         if (queryTimeout != -1) {
-          cache.testMaxQueryExecutionTime = queryTimeout;
+          cache.MAX_QUERY_EXECUTION_TIME = queryTimeout;
         } else {
-          cache.testMaxQueryExecutionTime = -1;
+          cache.MAX_QUERY_EXECUTION_TIME = -1;
         }
 
         if (criticalThreshold != 0) {
diff --git 
a/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/DeclarativeIndexCreationJUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/DeclarativeIndexCreationJUnitTest.java
index 4b873d6..3dd048e 100644
--- 
a/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/DeclarativeIndexCreationJUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/DeclarativeIndexCreationJUnitTest.java
@@ -35,6 +35,7 @@ import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionAttributes;
 import org.apache.geode.cache.query.CacheUtils;
 import org.apache.geode.distributed.DistributedSystem;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.util.test.TestUtil;
 
@@ -67,7 +68,7 @@ public class DeclarativeIndexCreationJUnitTest {
   @Test
   public void testAsynchronousIndexCreatedOnRoot_PortfoliosRegion() {
     Region root = cache.getRegion("/root/portfolios");
-    IndexManager im = IndexUtils.getIndexManager(root, true);
+    IndexManager im = IndexUtils.getIndexManager((InternalCache) cache, root, 
true);
     Collection coll = im.getIndexes();
     if (coll.size() > 0) {
       assertTrue(true);
@@ -82,7 +83,7 @@ public class DeclarativeIndexCreationJUnitTest {
   @Test
   public void testSynchronousIndexCreatedOnRoot_StringRegion() {
     Region root = cache.getRegion("/root/string");
-    IndexManager im = IndexUtils.getIndexManager(root, true);
+    IndexManager im = IndexUtils.getIndexManager((InternalCache) cache, root, 
true);
     Collection coll = im.getIndexes();
     if (coll.size() > 0) {
       assertTrue(true);
@@ -93,7 +94,7 @@ public class DeclarativeIndexCreationJUnitTest {
       fail(
           
"DeclarativeIndexCreationJUnitTest::testSynchronousIndexCreatedOnRoot_StringRegion
 Region:No index found in the root region");
     root = cache.getRegion("/root/string1");
-    im = IndexUtils.getIndexManager(root, true);
+    im = IndexUtils.getIndexManager((InternalCache) cache, root, true);
     if (!im.isIndexMaintenanceTypeSynchronous())
       fail(
           
"DeclarativeIndexCreationJUnitTest::testSynchronousIndexCreatedOnRoot_StringRegion:
 The index update type not synchronous if no index-update-type attribuet 
specified in cache.cml");
@@ -102,7 +103,7 @@ public class DeclarativeIndexCreationJUnitTest {
   @Test
   public void testSynchronousIndexCreatedOnRootRegion() {
     Region root = cache.getRegion("/root");
-    IndexManager im = IndexUtils.getIndexManager(root, true);
+    IndexManager im = IndexUtils.getIndexManager((InternalCache) cache, root, 
true);
     Collection coll = im.getIndexes();
     if (coll.size() > 0) {
       assertTrue(true);
diff --git 
a/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/IndexCreationInternalsJUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/IndexCreationInternalsJUnitTest.java
index bdd04dd..d6766fe 100644
--- 
a/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/IndexCreationInternalsJUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/IndexCreationInternalsJUnitTest.java
@@ -41,6 +41,7 @@ import org.apache.geode.cache.query.internal.CompiledPath;
 import org.apache.geode.cache.query.internal.CompiledRegion;
 import org.apache.geode.cache.query.internal.QCompiler;
 import org.apache.geode.cache.query.internal.types.TypeUtils;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.LocalRegion;
 import org.apache.geode.test.dunit.ThreadUtils;
 import org.apache.geode.test.junit.categories.IntegrationTest;
@@ -155,7 +156,7 @@ public class IndexCreationInternalsJUnitTest {
     try {
       Region rgn = CacheUtils.createRegion("dummy", null);
 
-      final IndexManager imgr = new IndexManager(rgn);
+      final IndexManager imgr = new IndexManager(CacheUtils.getCache(), rgn);
       ((LocalRegion) rgn).setIndexManager(imgr);
       String name = imgr.putCanonicalizedIteratorNameIfAbsent("dummy");
       assertTrue(
@@ -171,7 +172,7 @@ public class IndexCreationInternalsJUnitTest {
   public void testConcurrentGenerationOfCanonicalizedIteratorNames() {
     try {
       Region rgn = CacheUtils.createRegion("dummy", null);
-      final IndexManager imgr = new IndexManager(rgn);
+      final IndexManager imgr = new IndexManager(CacheUtils.getCache(), rgn);
       ((LocalRegion) rgn).setIndexManager(imgr);
 
       String name = imgr.putCanonicalizedIteratorNameIfAbsent("dummy");
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 8e4fcc7..8aaad15 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
@@ -37,6 +37,7 @@ import org.apache.geode.cache.CacheXmlException;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionAttributes;
 import org.apache.geode.distributed.DistributedSystem;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 
 /**
@@ -76,7 +77,7 @@ public class NewDeclarativeIndexCreationJUnitTest {
   @Test
   public void testAsynchronousIndexCreatedOnRoot_PortfoliosRegion() {
     Region root = this.cache.getRegion("/root/portfolios");
-    IndexManager im = IndexUtils.getIndexManager(root, true);
+    IndexManager im = IndexUtils.getIndexManager((InternalCache) cache, root, 
true);
     assertThat(im.getIndexes()).isNotEmpty();
 
     RegionAttributes ra = root.getAttributes();
@@ -86,21 +87,21 @@ public class NewDeclarativeIndexCreationJUnitTest {
   @Test
   public void testSynchronousIndexCreatedOnRoot_StringRegion() {
     Region root = this.cache.getRegion("/root/string");
-    IndexManager im = IndexUtils.getIndexManager(root, true);
+    IndexManager im = IndexUtils.getIndexManager((InternalCache) cache, root, 
true);
     assertThat(im.getIndexes()).isNotEmpty();
 
     RegionAttributes ra = root.getAttributes();
     assertThat(ra.getIndexMaintenanceSynchronous()).isTrue();
 
     root = this.cache.getRegion("/root/string1");
-    im = IndexUtils.getIndexManager(root, true);
+    im = IndexUtils.getIndexManager((InternalCache) cache, root, true);
     assertThat(im.isIndexMaintenanceTypeSynchronous()).isTrue();
   }
 
   @Test
   public void testSynchronousIndexCreatedOnRootRegion() {
     Region root = this.cache.getRegion("/root");
-    IndexManager im = IndexUtils.getIndexManager(root, true);
+    IndexManager im = IndexUtils.getIndexManager((InternalCache) cache, root, 
true);
     assertThat(im.getIndexes()).isNotEmpty();
 
     RegionAttributes ra = root.getAttributes();
@@ -115,7 +116,7 @@ public class NewDeclarativeIndexCreationJUnitTest {
   @Test
   public void testAsynchronousIndexCreatedOnPortfoliosRegionWithNewDTD() {
     Region root = this.cache.getRegion("/root/portfolios2");
-    IndexManager im = IndexUtils.getIndexManager(root, true);
+    IndexManager im = IndexUtils.getIndexManager((InternalCache) cache, root, 
true);
     assertThat(im.getIndexes()).isNotEmpty();
 
     RegionAttributes ra = root.getAttributes();
@@ -125,14 +126,14 @@ public class NewDeclarativeIndexCreationJUnitTest {
   @Test
   public void testSynchronousIndexCreatedOnStringRegionWithNewDTD() {
     Region root = this.cache.getRegion("/root/string2");
-    IndexManager im = IndexUtils.getIndexManager(root, true);;
+    IndexManager im = IndexUtils.getIndexManager((InternalCache) cache, root, 
true);;
     assertThat(im.getIndexes()).isNotEmpty();
 
     RegionAttributes ra = root.getAttributes();
     assertThat(ra.getIndexMaintenanceSynchronous()).isTrue();
 
     root = this.cache.getRegion("/root/string1");
-    im = IndexUtils.getIndexManager(root, true);
+    im = IndexUtils.getIndexManager((InternalCache) cache, root, true);
     assertThat(im.isIndexMaintenanceTypeSynchronous()).isTrue();
   }
 
diff --git 
a/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/PartitionedIndexJUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/PartitionedIndexJUnitTest.java
index 58b4ec2..8d48fd9 100644
--- 
a/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/PartitionedIndexJUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/PartitionedIndexJUnitTest.java
@@ -26,6 +26,7 @@ import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.query.IndexType;
 import org.apache.geode.distributed.DistributedSystem;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 
 @Category(IntegrationTest.class)
@@ -38,12 +39,12 @@ public class PartitionedIndexJUnitTest {
     final int THREAD_POOL_SIZE = 20;
 
     Region region = mock(Region.class);
-    Cache cache = mock(Cache.class);
+    InternalCache cache = mock(InternalCache.class);
     when(region.getCache()).thenReturn(cache);
     DistributedSystem distributedSystem = mock(DistributedSystem.class);
     when(cache.getDistributedSystem()).thenReturn(distributedSystem);
-    PartitionedIndex partitionedIndex = new 
PartitionedIndex(IndexType.FUNCTIONAL, "dummyString",
-        region, "dummyString", "dummyString", "dummyString");
+    PartitionedIndex partitionedIndex = new PartitionedIndex(cache, 
IndexType.FUNCTIONAL,
+        "dummyString", region, "dummyString", "dummyString", "dummyString");
     Runnable populateSetTask = () -> {
       for (int i = 0; i < DATA_SIZE_TO_BE_POPULATED; i++) {
         partitionedIndex.mapIndexKeys.add("" + i);
diff --git 
a/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/ProgRegionCreationIndexUpdateTypeJUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/ProgRegionCreationIndexUpdateTypeJUnitTest.java
index 6d2c364..272729f 100644
--- 
a/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/ProgRegionCreationIndexUpdateTypeJUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/cache/query/internal/index/ProgRegionCreationIndexUpdateTypeJUnitTest.java
@@ -18,7 +18,8 @@
  */
 package org.apache.geode.cache.query.internal.index;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static org.junit.Assert.fail;
 
 import java.util.Properties;
@@ -28,8 +29,13 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import org.apache.geode.cache.*;
+import org.apache.geode.cache.AttributesFactory;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionAttributes;
 import org.apache.geode.distributed.DistributedSystem;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 
 /**
@@ -65,7 +71,7 @@ public class ProgRegionCreationIndexUpdateTypeJUnitTest {
     attributesFactory.setIndexMaintenanceSynchronous(true);
     RegionAttributes regionAttributes = attributesFactory.create();
     Region region = cache.createRegion("region1", regionAttributes);
-    IndexManager im = IndexUtils.getIndexManager(region, true);
+    IndexManager im = IndexUtils.getIndexManager((InternalCache) cache, 
region, true);
 
     if (!im.isIndexMaintenanceTypeSynchronous())
       fail(
@@ -76,7 +82,7 @@ public class ProgRegionCreationIndexUpdateTypeJUnitTest {
     attributesFactory.setIndexMaintenanceSynchronous(false);
     regionAttributes = attributesFactory.create();
     region = cache.createRegion("region2", regionAttributes);
-    im = IndexUtils.getIndexManager(region, true);
+    im = IndexUtils.getIndexManager((InternalCache) cache, region, true);
     if (im.isIndexMaintenanceTypeSynchronous())
       fail(
           "IndexMaintenanceTest::testProgrammaticIndexUpdateType: Index Update 
Type found to be synchronous when it was marked explicitly asynchronous");
@@ -86,7 +92,7 @@ public class ProgRegionCreationIndexUpdateTypeJUnitTest {
     attributesFactory = new AttributesFactory();
     regionAttributes = attributesFactory.create();
     region = cache.createRegion("region3", regionAttributes);
-    im = IndexUtils.getIndexManager(region, true);
+    im = IndexUtils.getIndexManager((InternalCache) cache, region, true);
     if (!im.isIndexMaintenanceTypeSynchronous())
       fail(
           "IndexMaintenanceTest::testProgrammaticIndexUpdateType: Index Update 
Type found to be asynchronous when it default RegionAttributes should have 
created synchronous update type");
diff --git 
a/geode-cq/src/test/java/org/apache/geode/cache/query/dunit/QueryMonitorDUnitTest.java
 
b/geode-cq/src/test/java/org/apache/geode/cache/query/dunit/QueryMonitorDUnitTest.java
index 1e0e6a0..9772f22 100644
--- 
a/geode-cq/src/test/java/org/apache/geode/cache/query/dunit/QueryMonitorDUnitTest.java
+++ 
b/geode-cq/src/test/java/org/apache/geode/cache/query/dunit/QueryMonitorDUnitTest.java
@@ -220,12 +220,10 @@ public class QueryMonitorDUnitTest extends 
JUnit4CacheTestCase {
       Assert.fail("While starting CacheServer", ex);
     }
     Cache cache = getCache();
-    GemFireCacheImpl.getInstance().testMaxQueryExecutionTime = 
queryMonitorTime;
+    GemFireCacheImpl.MAX_QUERY_EXECUTION_TIME = queryMonitorTime;
     cache.getLogger().fine("#### RUNNING TEST : " + testName);
     DefaultQuery.testHook = new QueryTimeoutHook(queryMonitorTime);
     // ((GemFireCache)cache).testMaxQueryExecutionTime = queryMonitorTime;
-    System.out.println("MAX_QUERY_EXECUTION_TIME is set to: "
-        + ((GemFireCacheImpl) cache).testMaxQueryExecutionTime);
     return port;
   }
 
@@ -236,10 +234,8 @@ public class QueryMonitorDUnitTest extends 
JUnit4CacheTestCase {
         // Reset the test flag.
         Cache cache = getCache();
         DefaultQuery.testHook = null;
-        GemFireCacheImpl.getInstance().testMaxQueryExecutionTime = -1;
+        GemFireCacheImpl.MAX_QUERY_EXECUTION_TIME = -1;
         stopBridgeServer(getCache());
-        System.out.println("MAX_QUERY_EXECUTION_TIME is set to: "
-            + ((GemFireCacheImpl) cache).testMaxQueryExecutionTime);
       }
     };
     server.invoke(stopServer);
@@ -332,8 +328,7 @@ public class QueryMonitorDUnitTest extends 
JUnit4CacheTestCase {
 
   private void executeQueriesFromClient(int timeout) {
     try {
-      ClientCache anyInstance = ClientCacheFactory.getAnyInstance();
-      ((GemFireCacheImpl) anyInstance).testMaxQueryExecutionTime = timeout;
+      GemFireCacheImpl.MAX_QUERY_EXECUTION_TIME = timeout;
       Pool pool = PoolManager.find(poolName);
       QueryService queryService = pool.getQueryService();
       executeQueriesAgainstQueryService(queryService);
@@ -915,9 +910,6 @@ public class QueryMonitorDUnitTest extends 
JUnit4CacheTestCase {
     // do destroys and invalidates.
     server.invoke(new CacheSerializableRunnable("Create values") {
       public void run2() throws CacheException {
-        Cache cache = getCache();
-        System.out.println("TEST CQ MAX_QUERY_EXECUTION_TIME is set to: "
-            + ((GemFireCacheImpl) cache).testMaxQueryExecutionTime);
 
         Region region1 = getRootRegion().getSubregion(cqDUnitTest.regions[0]);
         for (int i = 1; i <= 5; i++) {
@@ -940,10 +932,6 @@ public class QueryMonitorDUnitTest extends 
JUnit4CacheTestCase {
     // do invalidates on fisrt five keys.
     server.invoke(new CacheSerializableRunnable("Create values") {
       public void run2() throws CacheException {
-        Cache cache = getCache();
-        System.out.println("TEST CQ MAX_QUERY_EXECUTION_TIME is set to: "
-            + ((GemFireCacheImpl) cache).testMaxQueryExecutionTime);
-
         Region region1 = getRootRegion().getSubregion(cqDUnitTest.regions[0]);
         for (int i = 1; i <= 5; i++) {
           region1.invalidate(CqQueryDUnitTest.KEY + i);

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

Reply via email to