geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [03/25] incubator-geode git commit: GEODE-1377: Refactoring as per review comments
Date Fri, 10 Jun 2016 22:00:02 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ad7fd7e1/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java
index f529196..015f340 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java
@@ -32,6 +32,8 @@ import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.*;
 
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+
 /**
  * Provides an implementation of <code>DistributionConfig</code> that
  * knows how to read the configuration file.

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ad7fd7e1/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java
index fee905c..8707a39 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java
@@ -18,7 +18,6 @@
 package com.gemstone.gemfire.distributed.internal;
 
 import com.gemstone.gemfire.distributed.DistributedSystem;
-import com.gemstone.gemfire.distributed.DistributedSystemConfigProperties;
 import com.gemstone.gemfire.internal.Config;
 import com.gemstone.gemfire.internal.ConfigSource;
 import com.gemstone.gemfire.internal.logging.InternalLogWriter;
@@ -32,6 +31,8 @@ import java.lang.reflect.Method;
 import java.net.InetAddress;
 import java.util.*;
 
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+
 /**
  * Provides accessor (and in some cases mutator) methods for the
  * various GemFire distribution configuration properties.  The
@@ -48,7 +49,7 @@ import java.util.*;
  *
  * @since GemFire 2.1
  */
-public interface DistributionConfig extends Config, LogConfig, DistributedSystemConfigProperties {
+public interface DistributionConfig extends Config, LogConfig {
 
   ////////////////////  Instance Methods  ////////////////////
 
@@ -872,7 +873,7 @@ public interface DistributionConfig extends Config, LogConfig, DistributedSystem
   /**
    * The name of the "SSLEnabled" property
    *
-   * @deprecated as of 8.0 use {@link #CLUSTER_SSL_ENABLED} instead.
+   * @deprecated as of 8.0 use {@link #CLUSTER_SSL_ENABLED_NAME} instead.
    */
   @ConfigAttribute(type = Boolean.class)
   String SSL_ENABLED_NAME = SSL_ENABLED;
@@ -917,7 +918,7 @@ public interface DistributionConfig extends Config, LogConfig, DistributedSystem
   /**
    * The name of the "SSLProtocols" property
    *
-   * @deprecated as of 8.0 use {@link #CLUSTER_SSL_PROTOCOLS} instead.
+   * @deprecated as of 8.0 use {@link #CLUSTER_SSL_PROTOCOLS_NAME} instead.
    */
   @ConfigAttribute(type = String.class)
   String SSL_PROTOCOLS_NAME = SSL_PROTOCOLS;
@@ -952,7 +953,7 @@ public interface DistributionConfig extends Config, LogConfig, DistributedSystem
   /**
    * The name of the "SSLCiphers" property
    *
-   * @deprecated as of 8.0 use {@link #CLUSTER_SSL_CIPHERS} instead.
+   * @deprecated as of 8.0 use {@link #CLUSTER_SSL_CIPHERS_NAME} instead.
    */
   @ConfigAttribute(type = String.class)
   String SSL_CIPHERS_NAME = SSL_CIPHERS;
@@ -987,7 +988,7 @@ public interface DistributionConfig extends Config, LogConfig, DistributedSystem
   /**
    * The name of the "SSLRequireAuthentication" property
    *
-   * @deprecated as of 8.0 use {@link #CLUSTER_SSL_REQUIRE_AUTHENTICATION} instead.
+   * @deprecated as of 8.0 use {@link #CLUSTER_SSL_REQUIRE_AUTHENTICATION_NAME} instead.
    */
   @ConfigAttribute(type = Boolean.class)
   String SSL_REQUIRE_AUTHENTICATION_NAME = SSL_REQUIRE_AUTHENTICATION;
@@ -2434,9 +2435,6 @@ public interface DistributionConfig extends Config, LogConfig, DistributedSystem
    */
   void setSecurity(String attName, String attValue);
 
-  /**
-   * For the "security-" prefixed properties
-   */
   String SECURITY_PREFIX_NAME = SECURITY_PREFIX;
 
   /**
@@ -3056,7 +3054,7 @@ public interface DistributionConfig extends Config, LogConfig, DistributedSystem
   /**
    * The name of the "jmx-manager-http-port" property.
    *
-   * @deprecated as of 8.0 use {@link #HTTP_SERVICE_PORT} instead.
+   * @deprecated as of 8.0 use {{@link #HTTP_SERVICE_PORT_NAME} instead.
    */
   @ConfigAttribute(type = Integer.class, min = 0, max = 65535)
   String JMX_MANAGER_HTTP_PORT_NAME = JMX_MANAGER_HTTP_PORT;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ad7fd7e1/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
index 3288e98..f037e95 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
@@ -34,6 +34,8 @@ import java.net.URL;
 import java.net.UnknownHostException;
 import java.util.*;
 
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+
 /**
  * Provides an implementation of <code>DistributionConfig</code> that
  * knows how to read the configuration file.

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ad7fd7e1/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/RuntimeDistributionConfigImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/RuntimeDistributionConfigImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/RuntimeDistributionConfigImpl.java
index 2c674f8..89cab6a 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/RuntimeDistributionConfigImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/RuntimeDistributionConfigImpl.java
@@ -25,6 +25,8 @@ import java.io.File;
 import java.util.Arrays;
 import java.util.List;
 
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+
 /**
  * Provides an implementation of <code>DistributionConfig</code> that
  * is used at runtime by a {@link InternalDistributedSystem}. It allows

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ad7fd7e1/geode-core/src/main/java/com/gemstone/gemfire/internal/AbstractConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/AbstractConfig.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/AbstractConfig.java
index 5d455ec..b3b46cc 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/AbstractConfig.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/AbstractConfig.java
@@ -161,7 +161,7 @@ public abstract class AbstractConfig implements Config {
         }
       }
       // hide the shiro-init configuration for now. Remove after we can allow customer to specify shiro.ini file
-      if(attName.equals(DistributionConfig.SECURITY_SHIRO_INIT)){
+      if(attName.equals(SECURITY_SHIRO_INIT)){
         continue;
       }
       pw.print(attName);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ad7fd7e1/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/LogConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/LogConfig.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/LogConfig.java
index 5100fc4..16e6654 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/LogConfig.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/logging/LogConfig.java
@@ -54,7 +54,7 @@ public interface LogConfig {
    * A name is optional and by default empty.
    * If set it must be unique in the ds.
    * When set its used by tools to help identify the member.
-   * <p> The default value is: {@link DistributionConfig#DEFAULT_NAME}.
+   * <p> The default value is: {@link com.gemstone.gemfire.distributed.internal.DistributionConfig#DEFAULT_NAME}.
    * @return the system's name.
    */
   String getName();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ad7fd7e1/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
index 838bfc6..961f68a 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtil.java
@@ -233,7 +233,7 @@ public class GeodeSecurityUtil {
     if(securityProps==null)
       return;
 
-    String shiroConfig = securityProps.getProperty(DistributionConfig.SECURITY_SHIRO_INIT);
+    String shiroConfig = securityProps.getProperty(SECURITY_SHIRO_INIT);
     String customAuthenticator =securityProps.getProperty(SECURITY_CLIENT_AUTHENTICATOR);
     if (!com.gemstone.gemfire.internal.lang.StringUtils.isBlank(shiroConfig)) {
       IniSecurityManagerFactory factory = new IniSecurityManagerFactory("classpath:"+shiroConfig);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ad7fd7e1/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/auth/GMSAuthenticatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/auth/GMSAuthenticatorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/auth/GMSAuthenticatorJUnitTest.java
index 3d88acd..9389916 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/auth/GMSAuthenticatorJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/auth/GMSAuthenticatorJUnitTest.java
@@ -158,38 +158,38 @@ public class GMSAuthenticatorJUnitTest {
 
   @Test
   public void testAuthenticatorWithEmptyAuth() throws Exception {
-    props.setProperty(DistributionConfig.SECURITY_PEER_AUTHENTICATOR, "");
+    props.setProperty(SECURITY_PEER_AUTHENTICATOR, "");
     String result = authenticator.authenticate(member, props, props, member);
     assertNull(result);
   }
 
   @Test
   public void testAuthenticatorWithNotExistAuth() throws Exception {
-    props.setProperty(DistributionConfig.SECURITY_PEER_AUTHENTICATOR, prefix + "NotExistAuth.create");
+    props.setProperty(SECURITY_PEER_AUTHENTICATOR, prefix + "NotExistAuth.create");
     verifyNegativeAuthenticate(props, props, "Authentication failed. See coordinator");
   }
 
   @Test
   public void testAuthenticatorWithNullAuth() throws Exception {
-    props.setProperty(DistributionConfig.SECURITY_PEER_AUTHENTICATOR, prefix + "TestAuthenticator1.create");
+    props.setProperty(SECURITY_PEER_AUTHENTICATOR, prefix + "TestAuthenticator1.create");
     verifyNegativeAuthenticate(props, props, "Authentication failed. See coordinator");
   }
 
   @Test
   public void testAuthenticatorWithNullCredential() throws Exception {
-    props.setProperty(DistributionConfig.SECURITY_PEER_AUTHENTICATOR, prefix + "TestAuthenticator1.create");
+    props.setProperty(SECURITY_PEER_AUTHENTICATOR, prefix + "TestAuthenticator1.create");
     verifyNegativeAuthenticate(null, props, "Failed to find credentials from");
   }
 
   @Test
   public void testAuthenticatorWithAuthInitFailure() throws Exception {
-    props.setProperty(DistributionConfig.SECURITY_PEER_AUTHENTICATOR, prefix + "TestAuthenticator2.create");
+    props.setProperty(SECURITY_PEER_AUTHENTICATOR, prefix + "TestAuthenticator2.create");
     verifyNegativeAuthenticate(props, props, "Authentication failed. See coordinator");
   }
 
   @Test
   public void testAuthenticatorWithAuthFailure() throws Exception {
-    props.setProperty(DistributionConfig.SECURITY_PEER_AUTHENTICATOR, prefix + "TestAuthenticator3.create");
+    props.setProperty(SECURITY_PEER_AUTHENTICATOR, prefix + "TestAuthenticator3.create");
     verifyNegativeAuthenticate(props, props, "Authentication failed. See coordinator");
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ad7fd7e1/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryMonitorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryMonitorDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryMonitorDUnitTest.java
index 98f5721..9107250 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryMonitorDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryMonitorDUnitTest.java
@@ -52,7 +52,6 @@ import com.gemstone.gemfire.cache.server.CacheServer;
 import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
 import com.gemstone.gemfire.cache30.CacheTestCase;
 import com.gemstone.gemfire.cache30.ClientServerTestCase;
-import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.test.dunit.Assert;
 import com.gemstone.gemfire.test.dunit.AsyncInvocation;
@@ -68,6 +67,8 @@ import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 import com.gemstone.gemfire.test.junit.categories.FlakyTest;
 
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+
 /**
  * Tests for QueryMonitoring service.
  *
@@ -76,14 +77,13 @@ import com.gemstone.gemfire.test.junit.categories.FlakyTest;
 @Category(DistributedTest.class)
 public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
 
-  private static int bridgeServerPort;
-
   private final String exampleRegionName = "exampleRegion";
   private final String exampleRegionName2 = "exampleRegion2";
   private final String poolName = "serverConnectionPool";
-
+  
+  
   /* Some of the queries are commented out as they were taking less time */
-  String[]  queryStr = {
+  String[] queryStr = {
       "SELECT ID FROM /root/exampleRegion p WHERE  p.ID > 100",
       "SELECT DISTINCT * FROM /root/exampleRegion x, x.positions.values WHERE  x.pk != '1000'",
       "SELECT DISTINCT * FROM /root/exampleRegion x, x.positions.values WHERE  x.pkid != '1'",
@@ -98,15 +98,15 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
       "SELECT DISTINCT ID FROM /root/exampleRegion p WHERE  p.status = 'active'",
       "SELECT DISTINCT pos FROM /root/exampleRegion p, p.positions.values pos WHERE  pos.secId IN SET('YHOO', 'IBM', 'AMZN')",
       "SELECT DISTINCT proj1:p, proj2:itrX FROM /root/exampleRegion p, (SELECT DISTINCT pos FROM /root/exampleRegion p, p.positions.values pos"
-      + " WHERE  pos.secId = 'YHOO') as itrX",
+          + " WHERE  pos.secId = 'YHOO') as itrX",
       "SELECT DISTINCT * FROM /root/exampleRegion p, (SELECT DISTINCT pos FROM /root/exampleRegion p, p.positions.values pos"
-      + " WHERE  pos.secId = 'YHOO') as itrX",
+          + " WHERE  pos.secId = 'YHOO') as itrX",
       "SELECT DISTINCT * FROM /root/exampleRegion p, (SELECT DISTINCT p.ID FROM /root/exampleRegion x"
-      + " WHERE  x.ID = p.ID) as itrX",
+          + " WHERE  x.ID = p.ID) as itrX",
       "SELECT DISTINCT * FROM /root/exampleRegion p, (SELECT DISTINCT pos FROM /root/exampleRegion x, x.positions.values pos"
-      + " WHERE  x.ID = p.ID) as itrX",
+          + " WHERE  x.ID = p.ID) as itrX",
       "SELECT DISTINCT x.ID FROM /root/exampleRegion x, x.positions.values v WHERE  "
-      + "v.secId = element(SELECT DISTINCT vals.secId FROM /root/exampleRegion p, p.positions.values vals WHERE  vals.secId = 'YHOO')",
+          + "v.secId = element(SELECT DISTINCT vals.secId FROM /root/exampleRegion p, p.positions.values vals WHERE  vals.secId = 'YHOO')",
       "SELECT DISTINCT * FROM /root/exampleRegion p, /root/exampleRegion2 p2 WHERE  p.status = 'active'",
       "SELECT DISTINCT p.ID FROM /root/exampleRegion p, /root/exampleRegion2 p2 WHERE  p.ID = p2.ID",
       "SELECT p.ID FROM /root/exampleRegion p, /root/exampleRegion2 p2 WHERE  p.ID = p2.ID and p.status = 'active' and p2.status = 'active'",
@@ -114,32 +114,32 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
       "SELECT DISTINCT p.ID FROM /root/exampleRegion p, /root/exampleRegion2 p2 WHERE  p.ID = p2.ID and p.ID > 100 and p2.ID < 100000",
       "SELECT p.ID FROM /root/exampleRegion p, /root/exampleRegion2 p2 WHERE  p.ID = p2.ID and p.ID > 100 and p2.ID < 100000 or p.status = p2.status",
       "SELECT p.ID FROM /root/exampleRegion p, /root/exampleRegion2 p2 WHERE  p.ID = p2.ID and p.ID > 100 and p2.ID < 100000 or p.status = 'active'",
-      "SELECT DISTINCT * FROM /root/exampleRegion p, positions.values pos WHERE   (p.ID > 1 or p.status = 'active') or (true AND pos.secId ='IBM')", 
+      "SELECT DISTINCT * FROM /root/exampleRegion p, positions.values pos WHERE   (p.ID > 1 or p.status = 'active') or (true AND pos.secId ='IBM')",
       "SELECT DISTINCT * FROM /root/exampleRegion p, positions.values pos WHERE   (p.ID > 1 or p.status = 'active') or (true AND pos.secId !='IBM')",
-      "SELECT DISTINCT structset.sos, structset.key " 
-      + "FROM /root/exampleRegion p, p.positions.values outerPos, " 
-      + "(SELECT DISTINCT key: key, sos: pos.sharesOutstanding "
-      + "FROM /root/exampleRegion.entries pf, pf.value.positions.values pos "
-      + "where outerPos.secId != 'IBM' AND "
-      + "pf.key IN (SELECT DISTINCT * FROM pf.value.collectionHolderMap['0'].arr)) structset "
-      + "where structset.sos > 2000",
+      "SELECT DISTINCT structset.sos, structset.key "
+          + "FROM /root/exampleRegion p, p.positions.values outerPos, "
+          + "(SELECT DISTINCT key: key, sos: pos.sharesOutstanding "
+          + "FROM /root/exampleRegion.entries pf, pf.value.positions.values pos "
+          + "where outerPos.secId != 'IBM' AND "
+          + "pf.key IN (SELECT DISTINCT * FROM pf.value.collectionHolderMap['0'].arr)) structset "
+          + "where structset.sos > 2000",
       "SELECT DISTINCT * "
-      + "FROM /root/exampleRegion p, p.positions.values outerPos, "
-      + "(SELECT DISTINCT key: key, sos: pos.sharesOutstanding "
-      + "FROM /root/exampleRegion.entries pf, pf.value.positions.values pos "
-      + "where outerPos.secId != 'IBM' AND " 
-      + "pf.key IN (SELECT DISTINCT * FROM pf.value.collectionHolderMap['0'].arr)) structset "
-      + "where structset.sos > 2000",
+          + "FROM /root/exampleRegion p, p.positions.values outerPos, "
+          + "(SELECT DISTINCT key: key, sos: pos.sharesOutstanding "
+          + "FROM /root/exampleRegion.entries pf, pf.value.positions.values pos "
+          + "where outerPos.secId != 'IBM' AND "
+          + "pf.key IN (SELECT DISTINCT * FROM pf.value.collectionHolderMap['0'].arr)) structset "
+          + "where structset.sos > 2000",
       "SELECT DISTINCT * FROM /root/exampleRegion p, p.positions.values position "
-      + "WHERE (true = null OR position.secId = 'SUN') AND true", 
+          + "WHERE (true = null OR position.secId = 'SUN') AND true",
   };
 
-  String[]  prQueryStr = {
+  String[] prQueryStr = {
       "SELECT ID FROM /root/exampleRegion p WHERE  p.ID > 100 and p.status = 'active'",
       "SELECT * FROM /root/exampleRegion WHERE  ID > 100 and status = 'active'",
       "SELECT DISTINCT * FROM /root/exampleRegion p WHERE   p.ID > 100 and p.status = 'active' and p.ID < 100000",
       "SELECT DISTINCT p.ID FROM /root/exampleRegion p WHERE p.ID > 100 and p.ID < 100000 and p.status = 'active'",
-      "SELECT DISTINCT * FROM /root/exampleRegion p, positions.values pos WHERE (p.ID > 1 or p.status = 'active') or (pos.secId != 'IBM')", 
+      "SELECT DISTINCT * FROM /root/exampleRegion p, positions.values pos WHERE (p.ID > 1 or p.status = 'active') or (pos.secId != 'IBM')",
   };
   
   private int numServers;
@@ -161,27 +161,20 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
     // avoid IllegalStateException from HandShake by connecting all vms tor
     // system before creating connection pools
     getSystem();
-
-    SerializableRunnable r = new SerializableRunnable("getSystem") {
-      public void run() {
+    
+    for (int i = 0; i < numServers; i++) {
+      host.getVM(i).invoke("getSystem", () -> {
         getSystem();
-      }
-    };
-
-    for (int i=0; i<numServers; i++) {
-      host.getVM(i).invoke(r);
+        return 0;
+      });
     }
-
-    r = new SerializableRunnable("getClientSystem") {
-      public void run() {
+    
+    for (int i = numServers; i < 4; i++) {
+      host.getVM(i).invoke("getClientSystem", () -> {
         Properties props = DistributedTestUtils.getAllDistributedSystemProperties(new Properties());
-        props.put(DistributionConfigImpl.LOCATORS, "");
+        props.put(LOCATORS, "");
         getSystem(props);
-      }
-    };
-
-    for (int i=numServers; i<4; i++) {
-      host.getVM(i).invoke(r);
+      });
     }
   }
 
@@ -189,100 +182,78 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
     createRegion(vm, false, null);
   }
 
-  public void createRegion(VM vm, final boolean eviction, final String dirName){
-    vm.invoke(new CacheSerializableRunnable("Create Regions") {
-      public void run2() throws CacheException {
-        AttributesFactory factory = new AttributesFactory();
-        factory.setScope(Scope.LOCAL);
-        factory.setDataPolicy(DataPolicy.REPLICATE);
-        // setting the eviction attributes.
-        if (eviction) {
-          File []f = new File[1];            
-          f[0] = new File(dirName);
-          f[0].mkdir();
-          DiskStoreFactory dsf = GemFireCacheImpl.getInstance().createDiskStoreFactory();
-          DiskStore ds1 = dsf.setDiskDirs(f).create("ds1");
-          factory.setDiskStoreName("ds1");
-          EvictionAttributes evictAttrs = EvictionAttributes
-            .createLRUEntryAttributes(100, EvictionAction.OVERFLOW_TO_DISK);
-          factory.setEvictionAttributes(evictAttrs);
-        }
-        // Create region
-        createRegion(exampleRegionName, factory.create());
-        createRegion(exampleRegionName2, factory.create());
-      }
-    });
+  private void createRegion(final boolean eviction, final String dirName) {
+    AttributesFactory factory = new AttributesFactory();
+    factory.setScope(Scope.LOCAL);
+    factory.setDataPolicy(DataPolicy.REPLICATE);
+    // setting the eviction attributes.
+    if (eviction) {
+      File[] f = new File[1];
+      f[0] = new File(dirName);
+      f[0].mkdir();
+      DiskStoreFactory dsf = GemFireCacheImpl.getInstance().createDiskStoreFactory();
+      DiskStore ds1 = dsf.setDiskDirs(f).create("ds1");
+      factory.setDiskStoreName("ds1");
+      EvictionAttributes evictAttrs = EvictionAttributes
+          .createLRUEntryAttributes(100, EvictionAction.OVERFLOW_TO_DISK);
+      factory.setEvictionAttributes(evictAttrs);
+    }
+    // Create region
+    createRegion(exampleRegionName, factory.create());
+    createRegion(exampleRegionName2, factory.create());
   }
 
-  public void createPRRegion(VM vm){
-    vm.invoke(new CacheSerializableRunnable("Create Regions") {
-      public void run2() throws CacheException {
-        AttributesFactory factory = new AttributesFactory();
-        //factory.setDataPolicy(DataPolicy.PARTITION);
-        factory.setPartitionAttributes((new PartitionAttributesFactory()).setTotalNumBuckets(8).create());
-        
-        createRegion(exampleRegionName, factory.create());
-        createRegion(exampleRegionName2, factory.create());
-        Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        exampleRegion.getCache().getLogger().fine("#### CREATING PR REGION....");
-      }
-    });
+  private void createPRRegion() {
+    AttributesFactory factory = new AttributesFactory();
+    //factory.setDataPolicy(DataPolicy.PARTITION);
+    factory.setPartitionAttributes((new PartitionAttributesFactory()).setTotalNumBuckets(8).create());
+
+    createRegion(exampleRegionName, factory.create());
+    createRegion(exampleRegionName2, factory.create());
+    Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
+    exampleRegion.getCache().getLogger().fine("#### CREATING PR REGION....");
   }
 
-  public void configServer(VM server, final int queryMonitorTime, final String testName){
-    SerializableRunnable initServer = new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        try {
-          startBridgeServer(0, false);
-        } catch (Exception ex) {
-          Assert.fail("While starting CacheServer", ex);
-        }
-        Cache cache = getCache();
-        GemFireCacheImpl.getInstance().TEST_MAX_QUERY_EXECUTION_TIME = queryMonitorTime;
-        cache.getLogger().fine("#### RUNNING TEST : " + testName);
-        DefaultQuery.testHook = new QueryTimeoutHook(queryMonitorTime);
-        //((GemFireCache)cache).TEST_MAX_QUERY_EXECUTION_TIME = queryMonitorTime;
-        System.out.println("MAX_QUERY_EXECUTION_TIME is set to: " + ((GemFireCacheImpl)cache).TEST_MAX_QUERY_EXECUTION_TIME);
-      }
-    };
-    server.invoke(initServer);
+  private int configServer(final int queryMonitorTime, final String testName) {
+    int port = 0;
+    try {
+      port = startBridgeServer(0, false);
+    } catch (Exception ex) {
+      Assert.fail("While starting CacheServer", ex);
+    }
+    Cache cache = getCache();
+    GemFireCacheImpl.getInstance().TEST_MAX_QUERY_EXECUTION_TIME = queryMonitorTime;
+    cache.getLogger().fine("#### RUNNING TEST : " + testName);
+    DefaultQuery.testHook = new QueryTimeoutHook(queryMonitorTime);
+    //((GemFireCache)cache).TEST_MAX_QUERY_EXECUTION_TIME = queryMonitorTime;
+    System.out.println("MAX_QUERY_EXECUTION_TIME is set to: " + ((GemFireCacheImpl) cache).TEST_MAX_QUERY_EXECUTION_TIME);
+    return port;
   }
 
   // Stop server
-  public void stopServer(VM server){
-    SerializableRunnable stopServer = new SerializableRunnable("Stop CacheServer") {      
+  private void stopServer(VM server) {
+    SerializableRunnable stopServer = new SerializableRunnable("Stop CacheServer") {
       public void run() {
         // Reset the test flag.
         Cache cache = getCache();
         DefaultQuery.testHook = null;
         GemFireCacheImpl.getInstance().TEST_MAX_QUERY_EXECUTION_TIME = -1;
         stopBridgeServer(getCache());
-        System.out.println("MAX_QUERY_EXECUTION_TIME is set to: " + ((GemFireCacheImpl)cache).TEST_MAX_QUERY_EXECUTION_TIME);
+        System.out.println("MAX_QUERY_EXECUTION_TIME is set to: " + ((GemFireCacheImpl) cache).TEST_MAX_QUERY_EXECUTION_TIME);
       }
     };
     server.invoke(stopServer);
   }
   
-  public void configClient(VM client, VM[] server){
-    final int[] port = new int[server.length];
-    for (int i=0; i < server.length; i++){
-      port[i] = server[i].invoke(() -> QueryMonitorDUnitTest.getCacheServerPort());
-    }
-    final String host0 = NetworkUtils.getServerHostName(server[0].getHost());
-
-    SerializableRunnable initClient = new CacheSerializableRunnable("Init client") {
-      public void run2() throws CacheException {
-        AttributesFactory factory = new AttributesFactory();
-        factory.setScope(Scope.LOCAL);
-        PoolFactory poolFactory = PoolManager.createFactory();
-        poolFactory.setReadTimeout(10 * 60 * 1000); // 10 mins.
-        ClientServerTestCase.configureConnectionPoolWithNameAndFactory(factory, host0, port, true, -1, -1, null, poolName, poolFactory);
-      }
-    };
-    client.invoke(initClient);    
+  private void configClient(String host, int... ports) {
+    AttributesFactory factory = new AttributesFactory();
+    factory.setScope(Scope.LOCAL);
+    PoolFactory poolFactory = PoolManager.createFactory();
+    poolFactory.setReadTimeout(10 * 60 * 1000); // 10 mins.
+    ClientServerTestCase.configureConnectionPoolWithNameAndFactory(factory, host, ports, true, -1, -1, null, poolName, poolFactory);
   }
   
-  public void verifyException(Exception e) {
+  private void verifyException(Exception e) {
     e.printStackTrace();
     String error = e.getMessage();
     if (e.getCause() != null) {
@@ -292,9 +263,9 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
     if (error.contains("Query execution cancelled after exceeding max execution time") ||
         error.contains("The Query completed sucessfully before it got canceled") ||
         error.contains("The QueryMonitor thread may be sleeping longer than the set sleep time") ||
-        error.contains("The query task could not be found but the query is marked as having been canceled")){
+        error.contains("The query task could not be found but the query is marked as having been canceled")) {
       // Expected exception.
-      return;      
+      return;
     }
 
     System.out.println("Unexpected exception:");
@@ -306,7 +277,7 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
     
     fail("Expected exception Not found. Expected exception with message: \n" +
         "\"Query execution taking more than the max execution time\"" + "\n Found \n" +
-        error);    
+        error);
   }
   
   /**
@@ -325,67 +296,77 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
     VM client3 = host.getVM(3);
 
     final int numberOfEntries = 100;
+    String serverHostName = NetworkUtils.getServerHostName(host);
 
     // Start server
-    configServer(server, 20, "testQueryMonitorClientServer"); // All the queries taking more than 20ms should be canceled by Query monitor.
-    createRegion(server);
+    int serverPort = server.invoke("Create BridgeServer",
+        () -> configServer(20, "testQueryMonitorClientServer")); // All the queries taking more than 20ms should be canceled by Query monitor.
+    server.invoke("createRegion", () -> createRegion());
     
     // Initialize server regions.
-    server.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        Region exampleRegion2 = getRootRegion().getSubregion(exampleRegionName2);
-        for (int i= (1 + 100); i <= (numberOfEntries + 100); i++) {
-          exampleRegion.put(""+i, new Portfolio(i));
-        }
-        for (int i= (1 + 100); i <= 200; i++) {
-          exampleRegion2.put(""+i, new Portfolio(i));
-        }
-      }
-    });
+    server.invoke("populatePortfolioRegions", () -> populatePortfolioRegions(numberOfEntries));
 
     // Initialize Client1 and create client regions.
-    configClient(client1, new VM[] {server});
-    createRegion(client1);
-    
+    client1.invoke("Init client", () -> configClient(serverHostName, serverPort));
+    client1.invoke("createRegion", () -> createRegion());
+
     // Initialize Client2 and create client regions.
-    configClient(client2, new VM[] {server});
-    createRegion(client2);
-    
+    client2.invoke("Init client", () -> configClient(serverHostName, serverPort));
+    client2.invoke("createRegion", () -> createRegion());
+
     // Initialize Client3 and create client regions.
-    configClient(client3, new VM[] {server});
-    createRegion(client3);
+    client3.invoke("Init client", () -> configClient(serverHostName, serverPort));
+    client3.invoke("createRegion", () -> createRegion());
 
     // Execute client queries
-    SerializableRunnable executeQuery = new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        try {
-          Pool pool = PoolManager.find(poolName);
-          QueryService queryService = pool.getQueryService();
-          for (int k=0; k < queryStr.length; k++) {
-            String qStr = queryStr[k];
-            try {
-              GemFireCacheImpl.getInstance().getLogger().fine("Executing query :" + qStr);
-              Query query = queryService.newQuery(qStr);
-              query.execute();
-              fail("The query should have been canceled by the QueryMonitor. Query: " + qStr);
-            }catch (Exception e){
-              verifyException(e);
-            }
-          }
-        } catch (Exception ex){
-          GemFireCacheImpl.getInstance().getLogger().fine("Exception creating the query service", ex);
-        }
-      }
-    };
 
-    client1.invoke(executeQuery);
-    client2.invoke(executeQuery);
-    client3.invoke(executeQuery);
+    client1.invoke("execute Queries", () -> executeQueriesFromClient(20));
+    client2.invoke("execute Queries", () -> executeQueriesFromClient(20));
+    client3.invoke("execute Queries", () -> executeQueriesFromClient(20));
 
     stopServer(server);
   }
 
+  private void executeQueriesFromClient(int timeout) {
+    try {
+      ClientCache anyInstance = ClientCacheFactory.getAnyInstance();
+      ((GemFireCacheImpl) anyInstance).TEST_MAX_QUERY_EXECUTION_TIME = timeout;
+      Pool pool = PoolManager.find(poolName);
+      QueryService queryService = pool.getQueryService();
+      executeQueriesAgainstQueryService(queryService);
+    } catch (Exception ex) {
+      GemFireCacheImpl.getInstance().getLogger().fine("Exception creating the query service", ex);
+    }
+  }
+
+  private void executeQueriesOnServer() {
+    try {
+      QueryService queryService = GemFireCacheImpl.getInstance().getQueryService();
+      executeQueriesAgainstQueryService(queryService);
+    } catch (Exception ex) {
+      GemFireCacheImpl.getInstance().getLogger().fine("Exception creating the query service", ex);
+    }
+  }
+
+  private void executeQueriesAgainstQueryService(QueryService queryService) {
+    for (int k = 0; k < queryStr.length; k++) {
+      String qStr = queryStr[k];
+      executeQuery(queryService, qStr);
+    }
+  }
+
+  private void executeQuery(QueryService queryService, String qStr) {
+    try {
+      GemFireCacheImpl.getInstance().getLogger().fine("Executing query :" + qStr);
+      Query query = queryService.newQuery(qStr);
+      query.execute();
+      fail("The query should have been canceled by the QueryMonitor. Query: " + qStr);
+    } catch (Exception e) {
+      System.out.println("queryStr = " + qStr);
+      verifyException(e);
+    }
+  }
+
   /**
    * Tests query execution from client to server (multi server).
    */
@@ -403,74 +384,35 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
 
     final int numberOfEntries = 100;
 
+    String serverHostName = NetworkUtils.getServerHostName(host);
+
     // Start server
-    configServer(server1, 20, "testQueryMonitorMultiClientMultiServer"); // All the queries taking more than 20ms should be canceled by Query monitor.
-    createRegion(server1);
+    int serverPort1 = server1.invoke("Create BridgeServer",
+        () -> configServer(20, "testQueryMonitorMultiClientMultiServer"));// All the queries taking more than 20ms should be canceled by Query monitor.
+    server1.invoke("createRegion", () -> createRegion());
 
-    configServer(server2, 20, "testQueryMonitorMultiClientMultiServer"); // All the queries taking more than 20ms should be canceled by Query monitor.
-    createRegion(server2);
+    int serverPort2 = server2.invoke("Create BridgeServer",
+        () -> configServer(20, "testQueryMonitorMultiClientMultiServer"));// All the queries taking more than 20ms should be canceled by Query monitor.
+    server2.invoke("createRegion", () -> createRegion());
 
     // Initialize server regions.
-    server1.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        Region exampleRegion2 = getRootRegion().getSubregion(exampleRegionName2);
-        for (int i= (1 + 100); i <= (numberOfEntries + 100); i++) {
-          exampleRegion.put(""+i, new Portfolio(i));
-        }
-        for (int i= (1 + 100); i <= 200; i++) {
-          exampleRegion2.put(""+i, new Portfolio(i));
-        }
-      }
-    });
+    server1.invoke("Create Bridge Server", () -> populatePortfolioRegions(numberOfEntries));
 
     // Initialize server regions.
-    server2.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        Region exampleRegion2 = getRootRegion().getSubregion(exampleRegionName2);
-        for (int i= (1 + 100); i <= (numberOfEntries + 100); i++) {
-          exampleRegion.put(""+i, new Portfolio(i));
-        }
-        for (int i= (1 + 100); i <= 200; i++) {
-          exampleRegion2.put(""+i, new Portfolio(i));
-        }
-      }
-    });
+    server2.invoke("Create Bridge Server", () -> populatePortfolioRegions(numberOfEntries));
 
     // Initialize Client1 and create client regions.
-    configClient(client1, new VM[] {server1, server2});
-    createRegion(client1);
-    
+    client1.invoke("Init client", () -> configClient(serverHostName, serverPort1, serverPort2));
+    client1.invoke("createRegion", () -> createRegion());
+
     // Initialize Client2 and create client regions.
-    configClient(client2, new VM[] {server1, server2});
-    createRegion(client2);
-    
+    client2.invoke("Init client", () -> configClient(serverHostName, serverPort1, serverPort2));
+    client2.invoke("createRegion", () -> createRegion());
+
     // Execute client queries
-    SerializableRunnable executeQuery = new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        try {
-          Pool pool = PoolManager.find(poolName);
-          QueryService queryService = pool.getQueryService();
-          for (int k=0; k < queryStr.length; k++) {
-            String qStr = queryStr[k];
-            try {
-              GemFireCacheImpl.getInstance().getLogger().fine("Executing query :" + qStr);
-              Query query = queryService.newQuery(qStr);
-              query.execute();
-              fail("The query should have been canceled by the QueryMonitor. Query: " + qStr);
-            }catch (Exception e){
-              verifyException(e);            
-            }
-          }
-        } catch (Exception ex){
-          GemFireCacheImpl.getInstance().getLogger().fine("Exception creating the query service", ex);
-        }
-      }
-    };
 
-    client1.invoke(executeQuery);
-    client2.invoke(executeQuery);
+    client1.invoke("executeQueriesFromClient", () -> executeQueriesFromClient(20));
+    client2.invoke("executeQueriesFromClient", () -> executeQueriesFromClient(20));
 
     stopServer(server1);
     stopServer(server2);
@@ -493,64 +435,24 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
     final int numberOfEntries = 100;
 
     // Start server
-    configServer(server1, 20, "testQueryExecutionLocally"); // All the queries taking more than 20ms should be canceled by Query monitor.
-    createRegion(server1);
+    server1.invoke("Create BridgeServer",
+        () -> configServer(20, "testQueryExecutionLocally"));// All the queries taking more than 20ms should be canceled by Query monitor.
+    server1.invoke("createRegion", () -> createRegion());
 
-    configServer(server2, 20, "testQueryExecutionLocally"); // All the queries taking more than 20ms should be canceled by Query monitor.
-    createRegion(server2);
+    server2.invoke("Create BridgeServer",
+        () -> configServer(20, "testQueryExecutionLocally"));// All the queries taking more than 20ms should be canceled by Query monitor.
+    server2.invoke("createRegion", () -> createRegion());
 
     // Initialize server regions.
-    server1.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        Region exampleRegion2 = getRootRegion().getSubregion(exampleRegionName2);
-        for (int i= (1 + 100); i <= (numberOfEntries + 100); i++) {
-          exampleRegion.put(""+i, new Portfolio(i));
-        }
-        for (int i= (1 + 100); i <= 200; i++) {
-          exampleRegion2.put(""+i, new Portfolio(i));
-        }
-      }
-    });
+    server1.invoke("Create Bridge Server", () -> populatePortfolioRegions(numberOfEntries));
 
     // Initialize server regions.
-    server2.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        Region exampleRegion2 = getRootRegion().getSubregion(exampleRegionName2);
-        for (int i= (1 + 100); i <= (numberOfEntries + 100); i++) {
-          exampleRegion.put(""+i, new Portfolio(i));
-        }
-        for (int i= (1 + 100); i <= 200; i++) {
-          exampleRegion2.put(""+i, new Portfolio(i));
-        }
-      }
-    });
+    server2.invoke("Create Bridge Server", () -> populatePortfolioRegions(numberOfEntries));
 
     // Execute server queries
-    SerializableRunnable executeQuery = new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        try {
-          QueryService queryService = GemFireCacheImpl.getInstance().getQueryService();
-          for (int k=0; k < queryStr.length; k++) {
-            String qStr = queryStr[k];
-            try {
-              GemFireCacheImpl.getInstance().getLogger().fine("Executing query :" + qStr);
-              Query query = queryService.newQuery(qStr);
-              query.execute();
-              fail("The query should have been canceled by the QueryMonitor. Query: " + qStr);
-            }catch (Exception e){ // TODO: this is too broad -- catch only the expected exception
-              verifyException(e);
-            }
-          }
-        } catch (Exception ex){ // TODO: do not catch or rethrow inside AssertionError
-          GemFireCacheImpl.getInstance().getLogger().fine("Exception creating the query service", ex);
-        }
-      }
-    };
 
-    server1.invoke(executeQuery);
-    server2.invoke(executeQuery);
+    server1.invoke("execute queries on Server", () -> executeQueriesOnServer());
+    server2.invoke("execute queries on Server", () -> executeQueriesOnServer());
 
     stopServer(server1);
     stopServer(server2);
@@ -572,39 +474,19 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
     final int numberOfEntries = 1000;
 
     // Start server
-    configServer(server1, 20, "testQueryExecutionLocally"); // All the queries taking more than 20ms should be canceled by Query monitor.
-    createRegion(server1);
+    server1.invoke("Create BridgeServer",
+        () -> configServer(20, "testQueryExecutionLocally"));// All the queries taking more than 20ms should be canceled by Query monitor.
+    server1.invoke("createRegion", () -> createRegion());
 
-    configServer(server2, 20, "testQueryExecutionLocally"); // All the queries taking more than 20ms should be canceled by Query monitor.
-    createRegion(server2);
+    server2.invoke("Create BridgeServer",
+        () -> configServer(20, "testQueryExecutionLocally"));// All the queries taking more than 20ms should be canceled by Query monitor.
+    server2.invoke("createRegion", () -> createRegion());
 
     // Initialize server regions.
-    server1.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        Region exampleRegion2 = getRootRegion().getSubregion(exampleRegionName2);
-        for (int i= (1 + 100); i <= (numberOfEntries + 100); i++) {
-          exampleRegion.put(""+i, new Portfolio(i));
-        }
-        for (int i= (1 + 100); i <= 200; i++) {
-          exampleRegion2.put(""+i, new Portfolio(i));
-        }
-      }
-    });
+    server1.invoke("populatePortfolioRegions", () -> populatePortfolioRegions(numberOfEntries));
 
     // Initialize server regions.
-    server2.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        Region exampleRegion2 = getRootRegion().getSubregion(exampleRegionName2);
-        for (int i= (1 + 100); i <= (numberOfEntries + 100); i++) {
-          exampleRegion.put(""+i, new Portfolio(i));
-        }
-        for (int i= (1 + 100); i <= 200; i++) {
-          exampleRegion2.put(""+i, new Portfolio(i));
-        }
-      }
-    });
+    server2.invoke("populatePortfolioRegions", () -> populatePortfolioRegions(numberOfEntries));
 
     // Execute server queries
     SerializableRunnable executeQuery = new CacheSerializableRunnable("Execute queries") {
@@ -612,28 +494,21 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
         try {
           QueryService queryService = GemFireCacheImpl.getInstance().getQueryService();
           String qStr = "SELECT DISTINCT * FROM /root/exampleRegion p, (SELECT DISTINCT pos FROM /root/exampleRegion x, x.positions.values pos"
-            + " WHERE  x.ID = p.ID) as itrX";
-          try {
-            GemFireCacheImpl.getInstance().getLogger().fine("Executing query :" + qStr);
-            Query query = queryService.newQuery(qStr);
-            query.execute();
-            fail("The query should have been canceled by the QueryMonitor. Query: " + qStr);
-          }catch (Exception e){
-            verifyException(e);
-          }
+              + " WHERE  x.ID = p.ID) as itrX";
+          executeQuery(queryService, qStr);
 
           // Create index and Perform cache op. Bug#44307
           queryService.createIndex("idIndex", IndexType.FUNCTIONAL, "ID", "/root/exampleRegion");
           queryService.createIndex("statusIndex", IndexType.FUNCTIONAL, "status", "/root/exampleRegion");
           Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-          for (int i= (1 + 100); i <= (numberOfEntries + 200); i++) {
-            exampleRegion.put(""+i, new Portfolio(i));
+          for (int i = (1 + 100); i <= (numberOfEntries + 200); i++) {
+            exampleRegion.put("" + i, new Portfolio(i));
           }
           
-        } catch (Exception ex){
+        } catch (Exception ex) {
           Assert.fail("Exception creating the query service", ex);
         }
-      }      
+      }
     };
 
     server1.invoke(executeQuery);
@@ -642,7 +517,18 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
     stopServer(server1);
     stopServer(server2);
   }
-  
+
+  private void populatePortfolioRegions(int numberOfEntries) {
+    Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
+    Region exampleRegion2 = getRootRegion().getSubregion(exampleRegionName2);
+    for (int i = (1 + 100); i <= (numberOfEntries + 100); i++) {
+      exampleRegion.put("" + i, new Portfolio(i));
+    }
+    for (int i = (1 + 100); i <= 200; i++) {
+      exampleRegion2.put("" + i, new Portfolio(i));
+    }
+  }
+
   /**
    * Tests query execution from client to server (multiple server) on Partition Region .
    */
@@ -660,73 +546,49 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
 
     final int numberOfEntries = 100;
 
+    String serverHostName = NetworkUtils.getServerHostName(host);
+
     // Start server
-    configServer(server1, 100, "testQueryMonitorMultiClientMultiServerOnPR"); // All the queries taking more than 100ms should be canceled by Query monitor.
-    createPRRegion(server1);
+    int serverPort1 = server1.invoke("configServer",
+        () -> configServer(20, "testQueryMonitorMultiClientMultiServerOnPR"));// All the queries taking more than 100ms should be canceled by Query monitor.
+    server1.invoke("createPRRegion", () -> createPRRegion());
 
-    configServer(server2, 100, "testQueryMonitorMultiClientMultiServerOnPR"); // All the queries taking more than 100ms should be canceled by Query monitor.
-    createPRRegion(server2);
+    int serverPort2 = server2.invoke("configServer",
+        () -> configServer(20, "testQueryMonitorMultiClientMultiServerOnPR"));// All the queries taking more than 100ms should be canceled by Query monitor.
+    server2.invoke("createPRRegion", () -> createPRRegion());
     
     // Initialize server regions.
-    server1.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        Region exampleRegion2 = getRootRegion().getSubregion(exampleRegionName2);
-        for (int i= (1 + 100); i <= (numberOfEntries + 100); i++) {
-          exampleRegion.put(""+i, new Portfolio(i));
-        }
-      }
-    });
+    server1.invoke("bulkInsertPorfolio", () -> bulkInsertPorfolio(101, numberOfEntries));
 
     // Initialize server regions.
-    server2.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        Region exampleRegion2 = getRootRegion().getSubregion(exampleRegionName2);
-        for (int i= (numberOfEntries + 100); i <= (numberOfEntries + numberOfEntries + 100); i++) {
-          exampleRegion.put(""+i, new Portfolio(i));
-        }
-      }
-    });
+    server2.invoke("bulkInsertPorfolio", () ->
+        bulkInsertPorfolio((numberOfEntries + 100), (numberOfEntries + numberOfEntries + 100)));
 
     // Initialize Client1 and create client regions.
-    configClient(client1, new VM[] {server1});
-    createRegion(client1);
+    client1.invoke("Init client", () -> configClient(serverHostName, serverPort1));
+    client1.invoke("createRegion", () -> createRegion());
     
     // Initialize Client2 and create client regions.
-    configClient(client2, new VM[] {server2});
-    createRegion(client2);
+    client2.invoke("Init client", () -> configClient(serverHostName, serverPort2));
+    client2.invoke("createRegion", () -> createRegion());
     
     // Execute client queries
-    SerializableRunnable executeQuery = new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        try {
-          Pool pool = PoolManager.find(poolName);
-          QueryService queryService = pool.getQueryService();
-          for (int k=0; k < prQueryStr.length; k++) {
-            String qStr = prQueryStr[k];
-            try {
-              GemFireCacheImpl.getInstance().getLogger().fine("Executing query :" + qStr);
-              Query query = queryService.newQuery(qStr);
-              query.execute();
-              fail("The query should have been canceled by the QueryMonitor. Query: " + qStr);
-            }catch (Exception e){
-              verifyException(e);            
-            }
-          }
-        } catch (Exception ex){
-          GemFireCacheImpl.getInstance().getLogger().fine("Exception creating the query service", ex);
-        }
-      }
-    };
 
-    client1.invoke(executeQuery);
-    client2.invoke(executeQuery);
+    client1.invoke("Execute Queries", () -> executeQueriesFromClient(20));
+    client2.invoke("Execute Queries", () -> executeQueriesFromClient(20));
 
     stopServer(server1);
     stopServer(server2);
   }
 
+  private void bulkInsertPorfolio(int startingId, int numberOfEntries) {
+    Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
+    Region exampleRegion2 = getRootRegion().getSubregion(exampleRegionName2);
+    for (int i = startingId; i <= (numberOfEntries + 100); i++) {
+      exampleRegion.put("" + i, new Portfolio(i));
+    }
+  }
+
   /**
    * Tests query execution on Partition Region, executes query locally.
    */
@@ -743,59 +605,31 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
     final int numberOfEntries = 100;
 
     // Start server
-    configServer(server1, 100, "testQueryMonitorMultiClientMultiServerOnPR"); // All the queries taking more than 100ms should be canceled by Query monitor.
-    createPRRegion(server1);
+    server1.invoke("configServer",
+        () -> configServer(20, "testQueryMonitorMultiClientMultiServerOnPR"));// All the queries taking more than 100ms should be canceled by Query monitor.
+    server1.invoke("Create Partition Regions", () -> createPRRegion());
 
-    configServer(server2, 100, "testQueryMonitorMultiClientMultiServerOnPR"); // All the queries taking more than 100ms should be canceled by Query monitor.
-    createPRRegion(server2);
+    server2.invoke("configServer",
+        () -> configServer(20, "testQueryMonitorMultiClientMultiServerOnPR"));// All the queries taking more than 100ms should be canceled by Query monitor.
+    server2.invoke("Create Partition Regions", () -> createPRRegion());
 
-    
     // Initialize server regions.
     server1.invoke(new CacheSerializableRunnable("Create Bridge Server") {
       public void run2() throws CacheException {
-        Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        Region exampleRegion2 = getRootRegion().getSubregion(exampleRegionName2);
-        for (int i= (1 + 100); i <= (numberOfEntries + 100); i++) {
-          exampleRegion.put(""+i, new Portfolio(i));
-        }
+        bulkInsertPorfolio(101, numberOfEntries);
       }
     });
 
     // Initialize server regions.
     server2.invoke(new CacheSerializableRunnable("Create Bridge Server") {
       public void run2() throws CacheException {
-        Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        Region exampleRegion2 = getRootRegion().getSubregion(exampleRegionName2);
-        for (int i= (numberOfEntries + 100); i <= (numberOfEntries + numberOfEntries + 100); i++) {
-          exampleRegion.put(""+i, new Portfolio(i));
-        }
+        bulkInsertPorfolio((numberOfEntries + 100), (numberOfEntries + numberOfEntries + 100));
       }
     });
     
     // Execute client queries
-    SerializableRunnable executeQuery = new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        try {
-          QueryService queryService = GemFireCacheImpl.getInstance().getQueryService();
-          for (int k=0; k < prQueryStr.length; k++) {
-            String qStr = prQueryStr[k];
-            try {
-              GemFireCacheImpl.getInstance().getLogger().fine("Executing query :" + qStr);
-              Query query = queryService.newQuery(qStr);
-              query.execute();
-              fail("The query should have been canceled by the QueryMonitor. Query: " + qStr);
-            }catch (Exception e){
-              verifyException(e);            
-            }
-          }
-        } catch (Exception ex){
-          GemFireCacheImpl.getInstance().getLogger().fine("Exception creating the query service", ex);
-        }
-      }
-    };
-
-    server1.invoke(executeQuery);
-    server2.invoke(executeQuery);
+    server1.invoke("execute queries on server", () -> executeQueriesOnServer());
+    server2.invoke("execute queries on server", () -> executeQueriesOnServer());
 
     stopServer(server1);
     stopServer(server2);
@@ -817,69 +651,42 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
 
     final int numberOfEntries = 100;
 
+    String serverHostName = NetworkUtils.getServerHostName(host);
+
     // Start server
-    configServer(server1, 20, "testQueryMonitorRegionWithEviction"); // All the queries taking more than 20ms should be canceled by Query monitor.
-    createRegion(server1, true, "server1_testQueryMonitorRegionWithEviction");
+    int serverPort1 = server1.invoke("Create BridgeServer",
+        () -> configServer(20, "testQueryMonitorRegionWithEviction"));// All the queries taking more than 20ms should be canceled by Query monitor.
+    server1.invoke("createRegion", () -> createRegion(true, "server1_testQueryMonitorRegionWithEviction"));
 
-    configServer(server2, 20, "testQueryMonitorRegionWithEviction"); // All the queries taking more than 20ms should be canceled by Query monitor.
-    createRegion(server2, true, "server2_testQueryMonitorRegionWithEviction");
+    int serverPort2 = server2.invoke("Create BridgeServer",
+        () -> configServer(20, "testQueryMonitorRegionWithEviction"));// All the queries taking more than 20ms should be canceled by Query monitor.
+    server2.invoke("createRegion", () -> createRegion(true, "server2_testQueryMonitorRegionWithEviction"));
 
-    
     // Initialize server regions.
     server1.invoke(new CacheSerializableRunnable("Create Bridge Server") {
       public void run2() throws CacheException {
-        Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        Region exampleRegion2 = getRootRegion().getSubregion(exampleRegionName2);
-        for (int i= (1 + 100); i <= (numberOfEntries + 100); i++) {
-          exampleRegion.put(""+i, new Portfolio(i));
-        }
+        bulkInsertPorfolio(101, numberOfEntries);
       }
     });
 
     // Initialize server regions.
     server2.invoke(new CacheSerializableRunnable("Create Bridge Server") {
       public void run2() throws CacheException {
-        Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        Region exampleRegion2 = getRootRegion().getSubregion(exampleRegionName2);
-        for (int i= (numberOfEntries + 100); i <= (numberOfEntries + numberOfEntries + 100); i++) {
-          exampleRegion.put(""+i, new Portfolio(i));
-        }
+        bulkInsertPorfolio((numberOfEntries + 100), (numberOfEntries + numberOfEntries + 100));
       }
     });
 
     // Initialize Client1 and create client regions.
-    configClient(client1, new VM[] {server1});
-    createRegion(client1);
+    client1.invoke("Init client", () -> configClient(serverHostName, serverPort1));
+    client1.invoke("createRegion", () -> createRegion());
     
     // Initialize Client2 and create client regions.
-    configClient(client2, new VM[] {server2});
-    createRegion(client2);
+    client2.invoke("Init client", () -> configClient(serverHostName, serverPort2));
+    client2.invoke("createRegion", () -> createRegion());
     
     // Execute client queries
-    SerializableRunnable executeQuery = new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        try {
-          Pool pool = PoolManager.find(poolName);
-          QueryService queryService = pool.getQueryService();
-          for (int k=0; k < prQueryStr.length; k++) {
-            String qStr = prQueryStr[k];
-            try {
-              GemFireCacheImpl.getInstance().getLogger().fine("Executing query :" + qStr);
-              Query query = queryService.newQuery(qStr);
-              query.execute();
-              fail("The query should have been canceled by the QueryMonitor. Query: " + qStr);
-            }catch (Exception e){
-              verifyException(e);
-            }
-          }
-        } catch (Exception ex){
-          GemFireCacheImpl.getInstance().getLogger().fine("Exception creating the query service", ex);
-        }
-      }
-    };
-
-    client1.invoke(executeQuery);
-    client2.invoke(executeQuery);
+    client1.invoke("Execute Queries", () -> executeQueriesFromClient(20));
+    client2.invoke("Execute Queries", () -> executeQueriesFromClient(20));
 
     stopServer(server1);
     stopServer(server2);
@@ -902,124 +709,76 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
 
     final int numberOfEntries = 100;
 
+    String serverHostName = NetworkUtils.getServerHostName(host);
+
     // Start server
-    configServer(server1, 20, "testQueryMonitorRegionWithIndex"); // All the queries taking more than 20ms should be canceled by Query monitor.
-    createRegion(server1);
+    int serverPort1 = server1.invoke("configServer",
+        () -> configServer(20, "testQueryMonitorRegionWithIndex"));// All the queries taking more than 20ms should be canceled by Query monitor.
+    server1.invoke("createRegion", () -> createRegion());
 
-    configServer(server2, 20, "testQueryMonitorRegionWithIndex"); // All the queries taking more than 20ms should be canceled by Query monitor.
-    createRegion(server2);
+    int serverPort2 = server2.invoke("configServer",
+        () -> configServer(20, "testQueryMonitorRegionWithIndex"));// All the queries taking more than 20ms should be canceled by Query monitor.
+    server2.invoke("createRegion", () -> createRegion());
 
-//    pause(1000);
-    
+    //    pause(1000);
 
     // Initialize server regions.
-    server1.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        Region exampleRegion2 = getRootRegion().getSubregion(exampleRegionName2);
-       
-        try {
-        // create index.
-        QueryService cacheQS = GemFireCacheImpl.getInstance().getQueryService();
-        cacheQS.createIndex("idIndex", IndexType.FUNCTIONAL,"p.ID","/root/exampleRegion p");
-        cacheQS.createIndex("statusIndex", IndexType.FUNCTIONAL,"p.status","/root/exampleRegion p");
-        cacheQS.createIndex("secIdIndex", IndexType.FUNCTIONAL,"pos.secId","/root/exampleRegion p, p.positions.values pos");
-        cacheQS.createIndex("posIdIndex", IndexType.FUNCTIONAL,"pos.Id","/root/exampleRegion p, p.positions.values pos");
-        cacheQS.createIndex("pkIndex", IndexType.PRIMARY_KEY, "pk", "/root/exampleRegion");
-        cacheQS.createIndex("pkidIndex", IndexType.PRIMARY_KEY, "pkid", "/root/exampleRegion");
-        cacheQS.createIndex("idIndex2", IndexType.FUNCTIONAL,"p2.ID","/root/exampleRegion2 p2");
-        cacheQS.createIndex("statusIndex2", IndexType.FUNCTIONAL,"p2.status","/root/exampleRegion2 p2");
-        cacheQS.createIndex("secIdIndex2", IndexType.FUNCTIONAL,"pos.secId","/root/exampleRegion2 p2, p2.positions.values pos");
-        cacheQS.createIndex("posIdIndex2", IndexType.FUNCTIONAL,"pos.Id","/root/exampleRegion2 p2, p2.positions.values pos");
-        cacheQS.createIndex("pkIndex2", IndexType.PRIMARY_KEY, "pk", "/root/exampleRegion2");
-        cacheQS.createIndex("pkidIndex2", IndexType.PRIMARY_KEY, "pkid", "/root/exampleRegion2");
-        } catch (Exception ex) {
-        }
-        for (int i= (1 + 100); i <= (numberOfEntries + 100); i++) {
-          exampleRegion.put(""+i, new Portfolio(i));
-        }
-        for (int i= (1 + 100); i <= (200 + 100); i++) {
-          exampleRegion2.put(""+i, new Portfolio(i));
-        }
-      }
-    });
+    server1.invoke("Create Indexes", () -> createIndexes(numberOfEntries));
 
     // Initialize server regions.
-    server2.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        Region exampleRegion2 = getRootRegion().getSubregion(exampleRegionName2);
-        // create index.
-        try {
-        QueryService cacheQS = GemFireCacheImpl.getInstance().getQueryService();
-        cacheQS.createIndex("idIndex", IndexType.FUNCTIONAL,"p.ID","/root/exampleRegion p");
-        cacheQS.createIndex("statusIndex", IndexType.FUNCTIONAL,"p.status","/root/exampleRegion p");
-        cacheQS.createIndex("secIdIndex", IndexType.FUNCTIONAL,"pos.secId","/root/exampleRegion p, p.positions.values pos");
-        cacheQS.createIndex("posIdIndex", IndexType.FUNCTIONAL,"pos.Id","/root/exampleRegion p, p.positions.values pos");
-        cacheQS.createIndex("pkIndex", IndexType.PRIMARY_KEY, "pk", "/root/exampleRegion");
-        cacheQS.createIndex("pkidIndex", IndexType.PRIMARY_KEY, "pkid", "/root/exampleRegion");
-        cacheQS.createIndex("idIndex2", IndexType.FUNCTIONAL,"p2.ID","/root/exampleRegion2 p2");
-        cacheQS.createIndex("statusIndex2", IndexType.FUNCTIONAL,"p2.status","/root/exampleRegion2 p2");
-        cacheQS.createIndex("secIdIndex2", IndexType.FUNCTIONAL,"pos.secId","/root/exampleRegion2 p2, p2.positions.values pos");
-        cacheQS.createIndex("posIdIndex2", IndexType.FUNCTIONAL,"pos.Id","/root/exampleRegion2 p2, p2.positions.values pos");
-        cacheQS.createIndex("pkIndex2", IndexType.PRIMARY_KEY, "pk", "/root/exampleRegion2");
-        cacheQS.createIndex("pkidIndex2", IndexType.PRIMARY_KEY, "pkid", "/root/exampleRegion2");
-        } catch (Exception ex) {
-        }
-
-        for (int i= (1 + 100); i <= (numberOfEntries + 100); i++) {
-          exampleRegion.put(""+i, new Portfolio(i));
-        }
-        for (int i= (1 + 100); i <= (200 + 100); i++) {
-          exampleRegion2.put(""+i, new Portfolio(i));
-        }
-      }
-    });
+    server2.invoke("Create Indexes", () -> createIndexes(numberOfEntries));
 
     // Initialize Client1 and create client regions.
-    configClient(client1, new VM[] {server1});
-    createRegion(client1);
-    
+    client1.invoke("Init client", () -> configClient(serverHostName, serverPort1));
+    client1.invoke("createRegion", () -> createRegion());
+
     // Initialize Client2 and create client regions.
-    configClient(client2, new VM[] {server2});
-    createRegion(client2);
-    
-    // Execute client queries
-    SerializableRunnable executeQuery = new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        try {
-          Pool pool = PoolManager.find(poolName);
-          QueryService queryService = pool.getQueryService();
-          for (int k=0; k < queryStr.length; k++) {
-            String qStr = queryStr[k];
-            try {
-              GemFireCacheImpl.getInstance().getLogger().fine("Executing query :" + qStr);
-              Query query = queryService.newQuery(qStr);
-              query.execute();
-              fail("The query should have been canceled by the QueryMonitor. Query: " + qStr);
-            }catch (Exception e){
-              verifyException(e);
-            }
-          }
-        } catch (Exception ex){
-          GemFireCacheImpl.getInstance().getLogger().fine("Exception creating the query service", ex);
-        }
-      }
-    };
+    client2.invoke("Init client", () -> configClient(serverHostName, serverPort2));
+    client2.invoke("createRegion", () -> createRegion());
 
-    client1.invoke(executeQuery);
-    client2.invoke(executeQuery);
+    // Execute client queries
+    client1.invoke("executeQueriesFromClient", () -> executeQueriesFromClient(20));
+    client2.invoke("executeQueriesFromClient", () -> executeQueriesFromClient(20));
 
     stopServer(server1);
     stopServer(server2);
   }
-  
+
+  private void createIndexes(int numberOfEntries) {
+    Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
+    Region exampleRegion2 = getRootRegion().getSubregion(exampleRegionName2);
+
+    try {
+      // create index.
+      QueryService cacheQS = GemFireCacheImpl.getInstance().getQueryService();
+      cacheQS.createIndex("idIndex", IndexType.FUNCTIONAL, "p.ID", "/root/exampleRegion p");
+      cacheQS.createIndex("statusIndex", IndexType.FUNCTIONAL, "p.status", "/root/exampleRegion p");
+      cacheQS.createIndex("secIdIndex", IndexType.FUNCTIONAL, "pos.secId", "/root/exampleRegion p, p.positions.values pos");
+      cacheQS.createIndex("posIdIndex", IndexType.FUNCTIONAL, "pos.Id", "/root/exampleRegion p, p.positions.values pos");
+      cacheQS.createIndex("pkIndex", IndexType.PRIMARY_KEY, "pk", "/root/exampleRegion");
+      cacheQS.createIndex("pkidIndex", IndexType.PRIMARY_KEY, "pkid", "/root/exampleRegion");
+      cacheQS.createIndex("idIndex2", IndexType.FUNCTIONAL, "p2.ID", "/root/exampleRegion2 p2");
+      cacheQS.createIndex("statusIndex2", IndexType.FUNCTIONAL, "p2.status", "/root/exampleRegion2 p2");
+      cacheQS.createIndex("secIdIndex2", IndexType.FUNCTIONAL, "pos.secId", "/root/exampleRegion2 p2, p2.positions.values pos");
+      cacheQS.createIndex("posIdIndex2", IndexType.FUNCTIONAL, "pos.Id", "/root/exampleRegion2 p2, p2.positions.values pos");
+      cacheQS.createIndex("pkIndex2", IndexType.PRIMARY_KEY, "pk", "/root/exampleRegion2");
+      cacheQS.createIndex("pkidIndex2", IndexType.PRIMARY_KEY, "pkid", "/root/exampleRegion2");
+    } catch (Exception ex) {
+    }
+    for (int i = (1 + 100); i <= (numberOfEntries + 100); i++) {
+      exampleRegion.put("" + i, new Portfolio(i));
+    }
+    for (int i = (1 + 100); i <= (200 + 100); i++) {
+      exampleRegion2.put("" + i, new Portfolio(i));
+    }
+  }
   
   protected CqQueryDUnitTest cqDUnitTest = new CqQueryDUnitTest();
 
   /**
    * The following CQ test is added to make sure TEST_MAX_QUERY_EXECUTION_TIME is reset
    * and is not affecting other query related tests.
+   *
    * @throws Exception
    */
   @Test
@@ -1050,51 +809,49 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
     
     // do destroys and invalidates.
     server.invoke(new CacheSerializableRunnable("Create values") {
-      public void run2() throws CacheException
-      {
+      public void run2() throws CacheException {
         Cache cache = getCache();
-        System.out.println("TEST CQ MAX_QUERY_EXECUTION_TIME is set to: " + ((GemFireCacheImpl)cache).TEST_MAX_QUERY_EXECUTION_TIME);
+        System.out.println("TEST CQ MAX_QUERY_EXECUTION_TIME is set to: " + ((GemFireCacheImpl) cache).TEST_MAX_QUERY_EXECUTION_TIME);
 
         Region region1 = getRootRegion().getSubregion(cqDUnitTest.regions[0]);
         for (int i = 1; i <= 5; i++) {
-          region1.destroy( CqQueryDUnitTest.KEY + i);
+          region1.destroy(CqQueryDUnitTest.KEY + i);
         }
       }
     });
     for (int i = 1; i <= 5; i++) {
-      cqDUnitTest.waitForDestroyed(client, name , CqQueryDUnitTest.KEY+i);
+      cqDUnitTest.waitForDestroyed(client, name, CqQueryDUnitTest.KEY + i);
     }
     // recreate the key values from 1 - 5
     cqDUnitTest.createValues(server, cqDUnitTest.regions[0], 5);
     // wait for all creates to arrive.
     for (int i = 1; i <= 5; i++) {
-      cqDUnitTest.waitForCreated(client, name , CqQueryDUnitTest.KEY+i);
+      cqDUnitTest.waitForCreated(client, name, CqQueryDUnitTest.KEY + i);
     }
     
     // do more puts to push first five key-value to disk.
     cqDUnitTest.createValues(server, cqDUnitTest.regions[0], 10);
     // do invalidates on fisrt five keys.
     server.invoke(new CacheSerializableRunnable("Create values") {
-      public void run2() throws CacheException
-      {
+      public void run2() throws CacheException {
         Cache cache = getCache();
-        System.out.println("TEST CQ MAX_QUERY_EXECUTION_TIME is set to: " + ((GemFireCacheImpl)cache).TEST_MAX_QUERY_EXECUTION_TIME);
+        System.out.println("TEST CQ MAX_QUERY_EXECUTION_TIME is set to: " + ((GemFireCacheImpl) cache).TEST_MAX_QUERY_EXECUTION_TIME);
 
         Region region1 = getRootRegion().getSubregion(cqDUnitTest.regions[0]);
         for (int i = 1; i <= 5; i++) {
-          region1.invalidate( CqQueryDUnitTest.KEY + i);
+          region1.invalidate(CqQueryDUnitTest.KEY + i);
         }
       }
     });
     // wait for invalidates now.
     for (int i = 1; i <= 5; i++) {
-      cqDUnitTest.waitForInvalidated(client, name , CqQueryDUnitTest.KEY+i);
+      cqDUnitTest.waitForInvalidated(client, name, CqQueryDUnitTest.KEY + i);
     }
-        
+
     // Close.
     cqDUnitTest.closeClient(client);
     cqDUnitTest.closeServer(server);
-  
+
   }
 
   /**
@@ -1115,17 +872,17 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
     final int numberOfEntries = 1000;
 
     // Start server
-    configServer(server1, 5, "testQueryExecutionLocally"); 
-    createPRRegion(server1);
+    server1.invoke("Create BridgeServer", () -> configServer(5, "testQueryExecutionLocally"));
+    server1.invoke("Create Partition Regions", () -> createPRRegion());
 
-    configServer(server2, 5, "testQueryExecutionLocally"); 
-    createPRRegion(server2);
+    server2.invoke("Create BridgeServer", () -> configServer(5, "testQueryExecutionLocally"));
+    server2.invoke("Create Partition Regions", () -> createPRRegion());
 
-    configServer(server3, 5, "testQueryExecutionLocally"); 
-    createPRRegion(server3);
-    
-    configServer(server4, 5, "testQueryExecutionLocally"); 
-    createPRRegion(server4);
+    server3.invoke("Create BridgeServer", () -> configServer(5, "testQueryExecutionLocally"));
+    server3.invoke("Create Partition Regions", () -> createPRRegion());
+
+    server4.invoke("Create BridgeServer", () -> configServer(5, "testQueryExecutionLocally"));
+    server4.invoke("Create Partition Regions", () -> createPRRegion());
     
     server1.invoke(new CacheSerializableRunnable("Create Bridge Server") {
       public void run2() throws CacheException {
@@ -1137,8 +894,8 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
           fail("Failed to create index.");
         }
         Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        for (int i= 100; i <= (numberOfEntries); i++) {
-          exampleRegion.put(""+i, new Portfolio(i));
+        for (int i = 100; i <= (numberOfEntries); i++) {
+          exampleRegion.put("" + i, new Portfolio(i));
         }
       }
     });
@@ -1147,22 +904,21 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
     AsyncInvocation ai1 = server1.invokeAsync(new CacheSerializableRunnable("Create Bridge Server") {
       public void run2() throws CacheException {
         Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        for (int j=0; j < 5; j++) {
-          for (int i= 1; i <= (numberOfEntries + 1000); i++) {
-            exampleRegion.put(""+i, new Portfolio(i));
+        for (int j = 0; j < 5; j++) {
+          for (int i = 1; i <= (numberOfEntries + 1000); i++) {
+            exampleRegion.put("" + i, new Portfolio(i));
           }
         }
         LogWriterUtils.getLogWriter().info("### Completed updates in server1 in testCacheOpAfterQueryCancel");
       }
     });
 
-   
     AsyncInvocation ai2 = server2.invokeAsync(new CacheSerializableRunnable("Create Bridge Server") {
       public void run2() throws CacheException {
         Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
-        for (int j=0; j < 5; j++) {
-          for (int i= (1 + 1000); i <= (numberOfEntries + 2000); i++) {
-            exampleRegion.put(""+i, new Portfolio(i));
+        for (int j = 0; j < 5; j++) {
+          for (int i = (1 + 1000); i <= (numberOfEntries + 2000); i++) {
+            exampleRegion.put("" + i, new Portfolio(i));
           }
         }
         LogWriterUtils.getLogWriter().info("### Completed updates in server2 in testCacheOpAfterQueryCancel");
@@ -1176,11 +932,11 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
           Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
           QueryService queryService = GemFireCacheImpl.getInstance().getQueryService();
           String qStr = "SELECT DISTINCT * FROM /root/exampleRegion p, p.positions.values pos1, p.positions.values pos" +
-            " where p.ID < pos.sharesOutstanding OR p.ID > 0 OR p.position1.mktValue > 0 " +
-            " OR pos.secId in SET ('SUN', 'IBM', 'YHOO', 'GOOG', 'MSFT', " +
-            " 'AOL', 'APPL', 'ORCL', 'SAP', 'DELL', 'RHAT', 'NOVL', 'HP')" +
-            " order by p.status, p.ID desc";
-          for (int i=0; i < 500; i++) {
+              " where p.ID < pos.sharesOutstanding OR p.ID > 0 OR p.position1.mktValue > 0 " +
+              " OR pos.secId in SET ('SUN', 'IBM', 'YHOO', 'GOOG', 'MSFT', " +
+              " 'AOL', 'APPL', 'ORCL', 'SAP', 'DELL', 'RHAT', 'NOVL', 'HP')" +
+              " order by p.status, p.ID desc";
+          for (int i = 0; i < 500; i++) {
             try {
               GemFireCacheImpl.getInstance().getLogger().info("Executing query :" + qStr);
               Query query = queryService.newQuery(qStr);
@@ -1188,19 +944,19 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
             } catch (QueryExecutionTimeoutException qet) {
               LogWriterUtils.getLogWriter().info("### Got Expected QueryExecutionTimeout exception. " +
                   qet.getMessage());
-              if (qet.getMessage().contains("cancelled after exceeding max execution")){
+              if (qet.getMessage().contains("cancelled after exceeding max execution")) {
                 LogWriterUtils.getLogWriter().info("### Doing a put operation");
-                exampleRegion.put(""+i, new Portfolio(i));
+                exampleRegion.put("" + i, new Portfolio(i));
               }
-            } catch (Exception e){
+            } catch (Exception e) {
               fail("Exception executing query." + e.getMessage());
             }
           }
           LogWriterUtils.getLogWriter().info("### Completed Executing queries in testCacheOpAfterQueryCancel");
-        } catch (Exception ex){
+        } catch (Exception ex) {
           Assert.fail("Exception creating the query service", ex);
         }
-      }      
+      }
     };
 
     AsyncInvocation ai3 = server3.invokeAsync(executeQuery);
@@ -1230,11 +986,11 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
     stopServer(server4);
   }
 
-  public void validateQueryMonitorThreadCnt(VM vm, final int threadCount, final int waitTime){
+  private void validateQueryMonitorThreadCnt(VM vm, final int threadCount, final int waitTime) {
     SerializableRunnable validateThreadCnt = new CacheSerializableRunnable("validateQueryMonitorThreadCnt") {
       public void run2() throws CacheException {
         Cache cache = getCache();
-        QueryMonitor qm = ((GemFireCacheImpl)cache).getQueryMonitor();
+        QueryMonitor qm = ((GemFireCacheImpl) cache).getQueryMonitor();
         if (qm == null) {
           fail("Didn't found query monitor.");
         }
@@ -1243,10 +999,10 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
           if (qm.getQueryMonitorThreadCount() != threadCount) {
             if (waited <= waitTime) {
               Wait.pause(10);
-              waited+=10;
+              waited += 10;
               continue;
             } else {
-              fail ("Didn't found expected monitoring thread. Expected: " + threadCount +
+              fail("Didn't found expected monitoring thread. Expected: " + threadCount +
                   " found :" + qm.getQueryMonitorThreadCount());
             }
           }
@@ -1263,52 +1019,48 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
    * deserializeValues and notifyBySubscription to serve up the
    * given region.
    */
-  protected void startBridgeServer(int port, boolean notifyBySubscription)
-  throws IOException {
+  protected int startBridgeServer(int port, boolean notifyBySubscription)
+      throws IOException {
 
     Cache cache = getCache();
     CacheServer bridge = cache.addCacheServer();
     bridge.setPort(port);
     bridge.setNotifyBySubscription(notifyBySubscription);
     bridge.start();
-    bridgeServerPort = bridge.getPort();
+    return bridge.getPort();
   }
 
   /**
    * Stops the bridge server that serves up the given cache.
    */
-  protected void stopBridgeServer(Cache cache) {
+  private void stopBridgeServer(Cache cache) {
     CacheServer bridge =
-      (CacheServer) cache.getCacheServers().iterator().next();
+        (CacheServer) cache.getCacheServers().iterator().next();
     bridge.stop();
     assertFalse(bridge.isRunning());
   }
 
-  private static int getCacheServerPort() {
-    return bridgeServerPort;
-  }
-  
   private class QueryTimeoutHook implements DefaultQuery.TestHook {
     long timeout;
-    public QueryTimeoutHook(long timeout) {
+
+    private QueryTimeoutHook(long timeout) {
       this.timeout = timeout;
     }
-    
+
     public void doTestHook(String description) {
       if (description.equals("6")) {
         try {
           Thread.sleep(timeout * 2);
-        }
-        catch (InterruptedException ie) {
+        } catch (InterruptedException ie) {
           Thread.currentThread().interrupt();
         }
       }
     }
-    
+
     public void doTestHook(int spot) {
       doTestHook("" + spot);
     }
-    
+
   }
 
 }


Mime
View raw message