geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aba...@apache.org
Subject [13/58] [abbrv] geode git commit: Revert "GEODE-2632: use immutable SecurityService impls to improve performance"
Date Mon, 17 Jul 2017 18:06:22 GMT
http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/java/org/apache/geode/security/SecurityManagerLifecycleIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/SecurityManagerLifecycleIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/security/SecurityManagerLifecycleIntegrationTest.java
deleted file mode 100644
index f00b03a..0000000
--- a/geode-core/src/test/java/org/apache/geode/security/SecurityManagerLifecycleIntegrationTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.security;
-
-import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
-import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
-import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.internal.security.SecurityService;
-import org.apache.geode.test.junit.categories.FlakyTest;
-import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.apache.geode.test.junit.categories.SecurityTest;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.util.Properties;
-
-@Category({IntegrationTest.class, SecurityTest.class})
-public class SecurityManagerLifecycleIntegrationTest {
-
-  private Properties securityProps;
-  private InternalCache cache;
-  private SecurityService securityService;
-
-  @Before
-  public void before() {
-    this.securityProps = new Properties();
-    this.securityProps.setProperty(SECURITY_MANAGER, SpySecurityManager.class.getName());
-
-    Properties props = new Properties();
-    props.putAll(this.securityProps);
-    props.setProperty(MCAST_PORT, "0");
-    props.setProperty(LOCATORS, "");
-
-    this.cache = (InternalCache) new CacheFactory(props).create();
-
-    this.securityService = this.cache.getSecurityService();
-  }
-
-  @After
-  public void after() {
-    if (this.cache != null && !this.cache.isClosed()) {
-      this.cache.close();
-    }
-  }
-
-  @Category(FlakyTest.class) // GEODE-1661
-  @Test
-  public void initAndCloseTest() {
-    SpySecurityManager ssm = (SpySecurityManager) this.securityService.getSecurityManager();
-    assertThat(ssm.getInitInvocationCount()).isEqualTo(1);
-    this.cache.close();
-    assertThat(ssm.getCloseInvocationCount()).isEqualTo(1);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/java/org/apache/geode/security/SimpleSecurityManagerTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/SimpleSecurityManagerTest.java b/geode-core/src/test/java/org/apache/geode/security/SimpleSecurityManagerTest.java
index 1c73b57..2d6fbca 100644
--- a/geode-core/src/test/java/org/apache/geode/security/SimpleSecurityManagerTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/SimpleSecurityManagerTest.java
@@ -12,6 +12,7 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
+
 package org.apache.geode.security;
 
 import static org.apache.geode.internal.Assert.assertTrue;

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/java/org/apache/geode/security/SimpleTestSecurityManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/SimpleTestSecurityManager.java b/geode-core/src/test/java/org/apache/geode/security/SimpleTestSecurityManager.java
index ac2d15d..c754376 100644
--- a/geode-core/src/test/java/org/apache/geode/security/SimpleTestSecurityManager.java
+++ b/geode-core/src/test/java/org/apache/geode/security/SimpleTestSecurityManager.java
@@ -23,23 +23,20 @@ import java.util.Properties;
  *
  * It is meant for demo purpose, not for production.
  *
- * Authentication: All users whose password matches the username are authenticated. e.g.
+ * Authentiation: All users whose password matches the username are authenticated. e.g.
  * username/password = test/test, user/user, admin/admin
  *
  * Authorization: users whose username is a substring (case insensitive) of the permission required
  * are authorized. e.g. username = data: is authorized for all data operations: data; data:manage
  * data:read data:write username = dataWrite: is authorized for data writes on all regions:
  * data:write data:write:regionA username = cluster: authorized for all cluster operations username
- * = clusterRead: authorized for all cluster read operations
+ * = cluserRead: authorzed for all cluster read operations
  *
  * a user could be a comma separated list of roles as well.
  */
 public class SimpleTestSecurityManager implements SecurityManager {
-
   @Override
-  public void init(final Properties securityProps) {
-    // nothing
-  }
+  public void init(final Properties securityProps) {}
 
   @Override
   public Object authenticate(final Properties credentials) throws AuthenticationFailedException {
@@ -63,7 +60,5 @@ public class SimpleTestSecurityManager implements SecurityManager {
   }
 
   @Override
-  public void close() {
-    // nothing
-  }
+  public void close() {}
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/java/org/apache/geode/security/SpySecurityManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/SpySecurityManager.java b/geode-core/src/test/java/org/apache/geode/security/SpySecurityManager.java
index 4523dae..1109489 100644
--- a/geode-core/src/test/java/org/apache/geode/security/SpySecurityManager.java
+++ b/geode-core/src/test/java/org/apache/geode/security/SpySecurityManager.java
@@ -15,16 +15,17 @@
 package org.apache.geode.security;
 
 import java.util.Properties;
-import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.geode.security.SecurityManager;
 
 public class SpySecurityManager extends SimpleTestSecurityManager {
 
-  private final AtomicInteger initInvoked = new AtomicInteger(0);
-  private final AtomicInteger closeInvoked = new AtomicInteger(0);
+  public int initInvoked = 0;
+  public int closeInvoked = 0;
 
   @Override
   public void init(final Properties securityProps) {
-    this.initInvoked.incrementAndGet();
+    initInvoked++;
   }
 
   @Override
@@ -34,14 +35,6 @@ public class SpySecurityManager extends SimpleTestSecurityManager {
 
   @Override
   public void close() {
-    this.closeInvoked.incrementAndGet();
-  }
-
-  public int getInitInvocationCount() {
-    return this.initInvoked.get();
-  }
-
-  public int getCloseInvocationCount() {
-    return this.closeInvoked.get();
+    closeInvoked++;
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java b/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java
index effbf25..72b8190 100755
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/DistributedTestUtils.java
@@ -14,9 +14,6 @@
  */
 package org.apache.geode.test.dunit;
 
-import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_AUTO_RECONNECT;
-import static org.junit.Assert.assertEquals;
-
 import org.apache.geode.distributed.DistributedSystem;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.distributed.internal.membership.gms.MembershipManagerHelper;
@@ -28,6 +25,10 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
 
+import static org.junit.Assert.assertEquals;
+
+import static org.apache.geode.distributed.ConfigurationProperties.*;
+
 /**
  * <code>DistributedTestUtils</code> provides static utility methods that affect the runtime
  * environment or artifacts generated by a DistributedTest.
@@ -154,7 +155,8 @@ public class DistributedTestUtils {
   }
 
   public static void unregisterDataSerializerInThisVM() {
-    // TODO: delete DataSerializerPropogationDUnitTest.successfullyLoadedTestDataSerializer = false;
+    // TODO:KIRK: delete DataSerializerPropogationDUnitTest.successfullyLoadedTestDataSerializer =
+    // false;
     // unregister all the Dataserializers
     InternalDataSerializer.reinitialize();
     // ensure that all are unregistered

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
index fa3e8c0..40cfe99 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
@@ -19,6 +19,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_
 import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.START_DEV_REST_API;
 
+import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.server.CacheServer;
@@ -26,7 +27,6 @@ import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.internal.cache.InternalCache;
 
 import java.io.File;
 import java.io.IOException;
@@ -51,7 +51,7 @@ import java.util.Properties;
  * use {@link LocatorServerStartupRule}.
  */
 public class ServerStarterRule extends MemberStarterRule<ServerStarterRule> implements Server {
-  private transient InternalCache cache;
+  private transient Cache cache;
   private transient CacheServer server;
   private int embeddedLocatorPort = -1;
   private boolean pdxPersistent = false;
@@ -74,7 +74,7 @@ public class ServerStarterRule extends MemberStarterRule<ServerStarterRule> impl
     super(workingDir);
   }
 
-  public InternalCache getCache() {
+  public Cache getCache() {
     return cache;
   }
 
@@ -161,7 +161,7 @@ public class ServerStarterRule extends MemberStarterRule<ServerStarterRule> impl
     CacheFactory cf = new CacheFactory(this.properties);
     cf.setPdxReadSerialized(pdxPersistent);
     cf.setPdxPersistent(pdxPersistent);
-    cache = (InternalCache) cf.create();
+    cache = cf.create();
     DistributionConfig config =
         ((InternalDistributedSystem) cache.getDistributedSystem()).getConfig();
     server = cache.addCacheServer();

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/java/org/apache/geode/test/fake/Fakes.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/fake/Fakes.java b/geode-core/src/test/java/org/apache/geode/test/fake/Fakes.java
index af38a1c..6a1e26f 100644
--- a/geode-core/src/test/java/org/apache/geode/test/fake/Fakes.java
+++ b/geode-core/src/test/java/org/apache/geode/test/fake/Fakes.java
@@ -34,7 +34,6 @@ import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
 import org.apache.geode.internal.cache.CachePerfStats;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.internal.security.SecurityService;
 
 /**
  * Factory methods for fake objects for use in test.
@@ -80,7 +79,6 @@ public class Fakes {
     when(cache.getDistributionManager()).thenReturn(distributionManager);
     when(cache.getCancelCriterion()).thenReturn(systemCancelCriterion);
     when(cache.getCachePerfStats()).thenReturn(mock(CachePerfStats.class));
-    when(cache.getSecurityService()).thenReturn(mock(SecurityService.class));
 
     when(system.getDistributedMember()).thenReturn(member);
     when(system.getConfig()).thenReturn(config);
@@ -88,7 +86,6 @@ public class Fakes {
     when(system.getCancelCriterion()).thenReturn(systemCancelCriterion);
     when(system.getClock()).thenReturn(clock);
     when(system.getLogWriter()).thenReturn(logger);
-    when(system.getSecurityService()).thenReturn(mock(SecurityService.class));
     when(system.createAtomicStatistics(any(), any(), anyLong())).thenReturn(stats);
     when(system.createAtomicStatistics(any(), any())).thenReturn(stats);
 

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
index b596c68..9a85c7e 100755
--- a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
+++ b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
@@ -450,7 +450,6 @@ org/apache/geode/internal/process/PidUnavailableException,true,-1660269538268828
 org/apache/geode/internal/process/signal/Signal,false,description:java/lang/String,name:java/lang/String,number:int,type:org/apache/geode/internal/process/signal/SignalType
 org/apache/geode/internal/process/signal/SignalEvent,false,signal:org/apache/geode/internal/process/signal/Signal
 org/apache/geode/internal/process/signal/SignalType,false,description:java/lang/String
-org/apache/geode/internal/security/SecurityServiceType,false
 org/apache/geode/internal/sequencelog/GraphType,false
 org/apache/geode/internal/sequencelog/model/GraphID,false,graphName:java/lang/String,type:org/apache/geode/internal/sequencelog/GraphType
 org/apache/geode/internal/size/ReflectionObjectSizer,false

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/resources/org/apache/geode/internal/security/SecurityServiceFactoryShiroIntegrationTest.ini
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/internal/security/SecurityServiceFactoryShiroIntegrationTest.ini b/geode-core/src/test/resources/org/apache/geode/internal/security/SecurityServiceFactoryShiroIntegrationTest.ini
deleted file mode 100644
index 8f7ffa7..0000000
--- a/geode-core/src/test/resources/org/apache/geode/internal/security/SecurityServiceFactoryShiroIntegrationTest.ini
+++ /dev/null
@@ -1,30 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# the users and roles in this file needs to be kept in sync with shiro.ini
-# since they are used by the same test to test ShiroUtil
-# -----------------------------------------------------------------------------
-# Users and their (optional) assigned roles
-# username = password, role1, role2, ..., roleN
-# -----------------------------------------------------------------------------
-[users]
-root = secret, admin
-
-# -----------------------------------------------------------------------------
-# Roles with assigned permissions
-# roleName = perm1, perm2, ..., permN
-# -----------------------------------------------------------------------------
-[roles]
-admin = *

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-core/src/test/resources/org/apache/geode/internal/security/shiro/ConfigInitializerIntegrationTest.ini
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/internal/security/shiro/ConfigInitializerIntegrationTest.ini b/geode-core/src/test/resources/org/apache/geode/internal/security/shiro/ConfigInitializerIntegrationTest.ini
deleted file mode 100644
index 8f7ffa7..0000000
--- a/geode-core/src/test/resources/org/apache/geode/internal/security/shiro/ConfigInitializerIntegrationTest.ini
+++ /dev/null
@@ -1,30 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# the users and roles in this file needs to be kept in sync with shiro.ini
-# since they are used by the same test to test ShiroUtil
-# -----------------------------------------------------------------------------
-# Users and their (optional) assigned roles
-# username = password, role1, role2, ..., roleN
-# -----------------------------------------------------------------------------
-[users]
-root = secret, admin
-
-# -----------------------------------------------------------------------------
-# Roles with assigned permissions
-# roleName = perm1, perm2, ..., permN
-# -----------------------------------------------------------------------------
-[roles]
-admin = *

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/CloseCQ.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/CloseCQ.java b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/CloseCQ.java
index 6748f7d..18929eb 100644
--- a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/CloseCQ.java
+++ b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/CloseCQ.java
@@ -14,6 +14,10 @@
  */
 package org.apache.geode.internal.cache.tier.sockets.command;
 
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.geode.cache.query.CqException;
 import org.apache.geode.cache.query.internal.cq.CqService;
 import org.apache.geode.cache.query.internal.cq.InternalCqQuery;
@@ -27,31 +31,27 @@ import org.apache.geode.internal.cache.tier.sockets.Message;
 import org.apache.geode.internal.cache.tier.sockets.ServerConnection;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.security.AuthorizeRequest;
-import org.apache.geode.internal.security.SecurityService;
 
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
 
 public class CloseCQ extends BaseCQCommand {
 
-  private static final CloseCQ singleton = new CloseCQ();
+  private final static CloseCQ singleton = new CloseCQ();
 
   public static Command getCommand() {
     return singleton;
   }
 
-  private CloseCQ() {
-    // nothing
-  }
+  private CloseCQ() {}
 
   @Override
-  public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection,
-      final SecurityService securityService, long start) throws IOException {
+  public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start)
+      throws IOException {
     CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
     ClientProxyMembershipID id = serverConnection.getProxyID();
     CacheServerStats stats = serverConnection.getCacheServerStats();
 
+    // Based on MessageType.QUERY
+    // Added by Rao 2/1/2007
     serverConnection.setAsTrue(REQUIRES_RESPONSE);
     serverConnection.setAsTrue(REQUIRES_CHUNKED_RESPONSE);
 
@@ -73,7 +73,7 @@ public class CloseCQ extends BaseCQCommand {
       return;
     }
 
-    securityService.authorizeDataManage();
+    this.securityService.authorizeDataManage();
 
     // Process CQ close request
     try {
@@ -89,16 +89,19 @@ public class CloseCQ extends BaseCQCommand {
 
       AuthorizeRequest authzRequest = serverConnection.getAuthzRequest();
       if (authzRequest != null) {
+        String queryStr = null;
+        Set cqRegionNames = null;
 
         if (cqQuery != null) {
-          String queryStr = cqQuery.getQueryString();
-          Set cqRegionNames = new HashSet();
-          cqRegionNames.add(cqQuery.getRegionName());
+          queryStr = cqQuery.getQueryString();
+          cqRegionNames = new HashSet();
+          cqRegionNames.add(((InternalCqQuery) cqQuery).getRegionName());
           authzRequest.closeCQAuthorize(cqName, queryStr, cqRegionNames);
         }
 
       }
-
+      // String cqNameWithClientId = new String(cqName + "__" +
+      // getMembershipID());
       cqService.closeCq(cqName, id);
       if (cqQuery != null)
         serverConnection.removeCq(cqName, cqQuery.isDurable());
@@ -120,9 +123,11 @@ public class CloseCQ extends BaseCQCommand {
         clientMessage.getTransactionId(), null, serverConnection);
     serverConnection.setAsTrue(RESPONDED);
 
-    long oldStart = start;
-    start = DistributionStats.getStatTime();
-    stats.incProcessCloseCqTime(start - oldStart);
+    {
+      long oldStart = start;
+      start = DistributionStats.getStatTime();
+      stats.incProcessCloseCqTime(start - oldStart);
+    }
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ.java b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ.java
index 04e32f8..86d53f5 100644
--- a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ.java
+++ b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ.java
@@ -14,6 +14,11 @@
  */
 package org.apache.geode.internal.cache.tier.sockets.command;
 
+import java.io.IOException;
+import java.util.Set;
+
+import org.apache.logging.log4j.Logger;
+
 import org.apache.geode.cache.operations.ExecuteCQOperationContext;
 import org.apache.geode.cache.query.CqException;
 import org.apache.geode.cache.query.Query;
@@ -34,28 +39,21 @@ import org.apache.geode.internal.cache.tier.sockets.ServerConnection;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.security.AuthorizeRequest;
-import org.apache.geode.internal.security.SecurityService;
-import org.apache.logging.log4j.Logger;
-
-import java.io.IOException;
-import java.util.Set;
 
 public class ExecuteCQ extends BaseCQCommand {
   protected static final Logger logger = LogService.getLogger();
 
-  private static final ExecuteCQ singleton = new ExecuteCQ();
+  private final static ExecuteCQ singleton = new ExecuteCQ();
 
   public static Command getCommand() {
     return singleton;
   }
 
-  private ExecuteCQ() {
-    // nothing
-  }
+  private ExecuteCQ() {}
 
   @Override
-  public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection,
-      final SecurityService securityService, long start) throws IOException, InterruptedException {
+  public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start)
+      throws IOException, InterruptedException {
     AcceptorImpl acceptor = serverConnection.getAcceptor();
     CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
     ClientProxyMembershipID id = serverConnection.getProxyID();
@@ -71,7 +69,7 @@ public class ExecuteCQ extends BaseCQCommand {
 
     Part isDurablePart = clientMessage.getPart(3);
     byte[] isDurableByte = isDurablePart.getSerializedForm();
-    boolean isDurable = !(isDurableByte == null || isDurableByte[0] == 0);
+    boolean isDurable = (isDurableByte == null || isDurableByte[0] == 0) ? false : true;
     if (logger.isDebugEnabled()) {
       logger.debug("{}: Received {} request from {} CqName: {} queryString: {}",
           serverConnection.getName(), MessageType.getString(clientMessage.getMessageType()),
@@ -118,14 +116,15 @@ public class ExecuteCQ extends BaseCQCommand {
       return;
     }
 
+    long oldstart = start;
     boolean sendResults = false;
+    boolean successQuery = false;
 
     if (clientMessage.getMessageType() == MessageType.EXECUTECQ_WITH_IR_MSG_TYPE) {
       sendResults = true;
     }
 
     // Execute the query and send the result-set to client.
-    boolean successQuery = false;
     try {
       if (query == null) {
         query = qService.newQuery(cqQueryString);
@@ -133,11 +132,11 @@ public class ExecuteCQ extends BaseCQCommand {
       }
       ((DefaultQuery) query).setIsCqQuery(true);
       successQuery = processQuery(clientMessage, query, cqQueryString, cqRegionNames, start,
-          cqQuery, executeCQContext, serverConnection, sendResults, securityService);
+          cqQuery, executeCQContext, serverConnection, sendResults);
 
       // Update the CQ statistics.
-      cqQuery.getVsdStats().setCqInitialResultsTime(DistributionStats.getStatTime() - start);
-      stats.incProcessExecuteCqWithIRTime(DistributionStats.getStatTime() - start);
+      cqQuery.getVsdStats().setCqInitialResultsTime((DistributionStats.getStatTime()) - oldstart);
+      stats.incProcessExecuteCqWithIRTime((DistributionStats.getStatTime()) - oldstart);
       // logger.fine("Time spent in execute with initial results :" +
       // DistributionStats.getStatTime() + ", " + oldstart);
     } finally { // To handle any exception.
@@ -145,7 +144,7 @@ public class ExecuteCQ extends BaseCQCommand {
       if (!successQuery) {
         try {
           cqServiceForExec.closeCq(cqName, id);
-        } catch (Exception ignore) {
+        } catch (Exception ex) {
           // Ignore.
         }
       }
@@ -158,7 +157,7 @@ public class ExecuteCQ extends BaseCQCommand {
           clientMessage.getTransactionId(), null, serverConnection);
 
       long start2 = DistributionStats.getStatTime();
-      stats.incProcessCreateCqTime(start2 - start);
+      stats.incProcessCreateCqTime(start2 - oldstart);
     }
     serverConnection.setAsTrue(RESPONDED);
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ61.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ61.java b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ61.java
index 77a608c..fcc45de 100755
--- a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ61.java
+++ b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/ExecuteCQ61.java
@@ -14,6 +14,11 @@
  */
 package org.apache.geode.internal.cache.tier.sockets.command;
 
+import java.io.IOException;
+import java.util.Set;
+
+import org.apache.logging.log4j.Logger;
+
 import org.apache.geode.cache.operations.ExecuteCQOperationContext;
 import org.apache.geode.cache.query.CqException;
 import org.apache.geode.cache.query.Query;
@@ -39,11 +44,6 @@ import org.apache.geode.internal.cache.vmotion.VMotionObserverHolder;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.security.AuthorizeRequest;
-import org.apache.geode.internal.security.SecurityService;
-import org.apache.logging.log4j.Logger;
-
-import java.io.IOException;
-import java.util.Set;
 
 /**
  * @since GemFire 6.1
@@ -51,19 +51,17 @@ import java.util.Set;
 public class ExecuteCQ61 extends BaseCQCommand {
   protected static final Logger logger = LogService.getLogger();
 
-  private static final ExecuteCQ61 singleton = new ExecuteCQ61();
+  private final static ExecuteCQ61 singleton = new ExecuteCQ61();
 
   public static Command getCommand() {
     return singleton;
   }
 
-  private ExecuteCQ61() {
-    // nothing
-  }
+  private ExecuteCQ61() {}
 
   @Override
-  public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection,
-      final SecurityService securityService, long start) throws IOException, InterruptedException {
+  public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start)
+      throws IOException, InterruptedException {
     AcceptorImpl acceptor = serverConnection.getAcceptor();
     CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
     ClientProxyMembershipID id = serverConnection.getProxyID();
@@ -79,7 +77,7 @@ public class ExecuteCQ61 extends BaseCQCommand {
 
     Part isDurablePart = clientMessage.getPart(3);
     byte[] isDurableByte = isDurablePart.getSerializedForm();
-    boolean isDurable = !(isDurableByte == null || isDurableByte[0] == 0);
+    boolean isDurable = (isDurableByte == null || isDurableByte[0] == 0) ? false : true;
     // region data policy
     Part regionDataPolicyPart = clientMessage.getPart(clientMessage.getNumberOfParts() - 1);
     byte[] regionDataPolicyPartBytes = regionDataPolicyPart.getSerializedForm();
@@ -157,7 +155,9 @@ public class ExecuteCQ61 extends BaseCQCommand {
       return;
     }
 
+    long oldstart = start;
     boolean sendResults = false;
+    boolean successQuery = false;
 
     if (clientMessage.getMessageType() == MessageType.EXECUTECQ_WITH_IR_MSG_TYPE) {
       sendResults = true;
@@ -165,9 +165,8 @@ public class ExecuteCQ61 extends BaseCQCommand {
 
     // Execute the query only if it is execute with initial results or
     // if it is a non PR query with execute query and maintain keys flags set
-    boolean successQuery = false;
-    if (sendResults || CqServiceImpl.EXECUTE_QUERY_DURING_INIT && CqServiceProvider.MAINTAIN_KEYS
-        && !cqQuery.isPR()) {
+    if (sendResults || (CqServiceImpl.EXECUTE_QUERY_DURING_INIT && CqServiceProvider.MAINTAIN_KEYS
+        && !cqQuery.isPR())) {
       // Execute the query and send the result-set to client.
       try {
         if (query == null) {
@@ -176,12 +175,12 @@ public class ExecuteCQ61 extends BaseCQCommand {
         }
         ((DefaultQuery) query).setIsCqQuery(true);
         successQuery = processQuery(clientMessage, query, cqQueryString, cqRegionNames, start,
-            cqQuery, executeCQContext, serverConnection, sendResults, securityService);
+            cqQuery, executeCQContext, serverConnection, sendResults);
 
 
         // Update the CQ statistics.
-        cqQuery.getVsdStats().setCqInitialResultsTime(DistributionStats.getStatTime() - start);
-        stats.incProcessExecuteCqWithIRTime(DistributionStats.getStatTime() - start);
+        cqQuery.getVsdStats().setCqInitialResultsTime((DistributionStats.getStatTime()) - oldstart);
+        stats.incProcessExecuteCqWithIRTime((DistributionStats.getStatTime()) - oldstart);
         // logger.fine("Time spent in execute with initial results :" +
         // DistributionStats.getStatTime() + ", " + oldstart);
       } finally { // To handle any exception.
@@ -189,7 +188,7 @@ public class ExecuteCQ61 extends BaseCQCommand {
         if (!successQuery) {
           try {
             cqServiceForExec.closeCq(cqName, id);
-          } catch (Exception ignored) {
+          } catch (Exception ex) {
             // Ignore.
           }
         }
@@ -208,9 +207,10 @@ public class ExecuteCQ61 extends BaseCQCommand {
           clientMessage.getTransactionId(), null, serverConnection);
 
       long start2 = DistributionStats.getStatTime();
-      stats.incProcessCreateCqTime(start2 - start);
+      stats.incProcessCreateCqTime(start2 - oldstart);
     }
     serverConnection.setAsTrue(RESPONDED);
+
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetCQStats.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetCQStats.java b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetCQStats.java
index a37263f..0fab303 100644
--- a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetCQStats.java
+++ b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetCQStats.java
@@ -14,6 +14,8 @@
  */
 package org.apache.geode.internal.cache.tier.sockets.command;
 
+import java.io.IOException;
+
 import org.apache.geode.cache.query.internal.cq.CqService;
 import org.apache.geode.distributed.internal.DistributionStats;
 import org.apache.geode.internal.cache.tier.CachedRegionHelper;
@@ -22,25 +24,20 @@ import org.apache.geode.internal.cache.tier.MessageType;
 import org.apache.geode.internal.cache.tier.sockets.CacheServerStats;
 import org.apache.geode.internal.cache.tier.sockets.Message;
 import org.apache.geode.internal.cache.tier.sockets.ServerConnection;
-import org.apache.geode.internal.security.SecurityService;
-
-import java.io.IOException;
 
 public class GetCQStats extends BaseCQCommand {
 
-  private static final GetCQStats singleton = new GetCQStats();
+  private final static GetCQStats singleton = new GetCQStats();
 
   public static Command getCommand() {
     return singleton;
   }
 
-  private GetCQStats() {
-    // nothing
-  }
+  private GetCQStats() {}
 
   @Override
-  public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection,
-      final SecurityService securityService, long start) throws IOException {
+  public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start)
+      throws IOException {
     CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
 
     CacheServerStats stats = serverConnection.getCacheServerStats();
@@ -70,7 +67,7 @@ public class GetCQStats extends BaseCQCommand {
       return;
     }
 
-    securityService.authorizeClusterRead();
+    this.securityService.authorizeClusterRead();
     // Process the cq request
     try {
       // make sure the cqservice has been created
@@ -88,9 +85,11 @@ public class GetCQStats extends BaseCQCommand {
         clientMessage.getTransactionId(), null, serverConnection);
     serverConnection.setAsTrue(RESPONDED);
 
-    long oldStart = start;
-    start = DistributionStats.getStatTime();
-    stats.incProcessGetCqStatsTime(start - oldStart);
+    {
+      long oldStart = start;
+      start = DistributionStats.getStatTime();
+      stats.incProcessGetCqStatsTime(start - oldStart);
+    }
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetDurableCQs.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetDurableCQs.java b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetDurableCQs.java
index 1ba5fed..c14bd72 100755
--- a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetDurableCQs.java
+++ b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/GetDurableCQs.java
@@ -32,23 +32,20 @@ import org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID;
 import org.apache.geode.internal.cache.tier.sockets.Message;
 import org.apache.geode.internal.cache.tier.sockets.ServerConnection;
 import org.apache.geode.internal.security.AuthorizeRequest;
-import org.apache.geode.internal.security.SecurityService;
 
 public class GetDurableCQs extends BaseCQCommand {
 
-  private static final GetDurableCQs singleton = new GetDurableCQs();
+  private final static GetDurableCQs singleton = new GetDurableCQs();
 
   public static Command getCommand() {
     return singleton;
   }
 
-  private GetDurableCQs() {
-    // nothing
-  }
+  private GetDurableCQs() {}
 
   @Override
-  public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection,
-      final SecurityService securityService, long start) throws IOException, InterruptedException {
+  public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start)
+      throws IOException, InterruptedException {
     AcceptorImpl acceptor = serverConnection.getAcceptor();
     CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
     ClientProxyMembershipID id = serverConnection.getProxyID();
@@ -63,11 +60,13 @@ public class GetDurableCQs extends BaseCQCommand {
           serverConnection.getSocketString());
     }
 
+    DefaultQueryService qService = null;
+    CqService cqServiceForExec = null;
+
     try {
-      DefaultQueryService qService =
-          (DefaultQueryService) crHelper.getCache().getLocalQueryService();
+      qService = (DefaultQueryService) crHelper.getCache().getLocalQueryService();
 
-      securityService.authorizeClusterRead();
+      this.securityService.authorizeClusterRead();
 
       // Authorization check
       AuthorizeRequest authzRequest = serverConnection.getAuthzRequest();
@@ -75,7 +74,7 @@ public class GetDurableCQs extends BaseCQCommand {
         authzRequest.getDurableCQsAuthorize();
       }
 
-      CqService cqServiceForExec = qService.getCqService();
+      cqServiceForExec = qService.getCqService();
       List<String> durableCqs = cqServiceForExec.getAllDurableClientCqs(id);
 
       ChunkedMessage chunkedResponseMsg = serverConnection.getChunkedResponseMessage();
@@ -85,7 +84,7 @@ public class GetDurableCQs extends BaseCQCommand {
 
       List durableCqList = new ArrayList(MAXIMUM_CHUNK_SIZE);
       final boolean isTraceEnabled = logger.isTraceEnabled();
-      for (Iterator<String> it = durableCqs.iterator(); it.hasNext();) {
+      for (Iterator it = durableCqs.iterator(); it.hasNext();) {
         Object durableCqName = it.next();
         durableCqList.add(durableCqName);
         if (isTraceEnabled) {
@@ -104,8 +103,10 @@ public class GetDurableCQs extends BaseCQCommand {
     } catch (CqException cqe) {
       sendCqResponse(MessageType.CQ_EXCEPTION_TYPE, "", clientMessage.getTransactionId(), cqe,
           serverConnection);
+      return;
     } catch (Exception e) {
       writeChunkedException(clientMessage, e, serverConnection);
+      return;
     }
   }
 
@@ -119,11 +120,12 @@ public class GetDurableCQs extends BaseCQCommand {
 
     if (logger.isDebugEnabled()) {
       logger.debug("{}: Sending {} durableCQs response chunk{}", servConn.getName(),
-          lastChunk ? " last " : " ",
-          logger.isTraceEnabled() ? " keys=" + list + " chunk=<" + chunkedResponseMsg + ">" : "");
+          (lastChunk ? " last " : " "),
+          (logger.isTraceEnabled() ? " keys=" + list + " chunk=<" + chunkedResponseMsg + ">" : ""));
     }
 
     chunkedResponseMsg.sendChunk(servConn);
   }
 
+
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/MonitorCQ.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/MonitorCQ.java b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/MonitorCQ.java
index f5e31df..5f0118b 100644
--- a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/MonitorCQ.java
+++ b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/MonitorCQ.java
@@ -14,6 +14,8 @@
  */
 package org.apache.geode.internal.cache.tier.sockets.command;
 
+import java.io.IOException;
+
 import org.apache.geode.cache.query.CqException;
 import org.apache.geode.cache.query.internal.cq.CqService;
 import org.apache.geode.internal.cache.tier.CachedRegionHelper;
@@ -22,25 +24,20 @@ import org.apache.geode.internal.cache.tier.MessageType;
 import org.apache.geode.internal.cache.tier.sockets.Message;
 import org.apache.geode.internal.cache.tier.sockets.ServerConnection;
 import org.apache.geode.internal.i18n.LocalizedStrings;
-import org.apache.geode.internal.security.SecurityService;
-
-import java.io.IOException;
 
 public class MonitorCQ extends BaseCQCommand {
 
-  private static final MonitorCQ singleton = new MonitorCQ();
+  private final static MonitorCQ singleton = new MonitorCQ();
 
   public static Command getCommand() {
     return singleton;
   }
 
-  private MonitorCQ() {
-    // nothing
-  }
+  private MonitorCQ() {}
 
   @Override
-  public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection,
-      final SecurityService securityService, long start) throws IOException {
+  public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start)
+      throws IOException {
     CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
     serverConnection.setAsTrue(REQUIRES_RESPONSE);
     serverConnection.setAsTrue(REQUIRES_CHUNKED_RESPONSE);
@@ -74,10 +71,10 @@ public class MonitorCQ extends BaseCQCommand {
     if (logger.isDebugEnabled()) {
       logger.debug("{}: Received MonitorCq request from {} op: {}{}", serverConnection.getName(),
           serverConnection.getSocketString(), op,
-          regionName != null ? " RegionName: " + regionName : "");
+          (regionName != null) ? " RegionName: " + regionName : "");
     }
 
-    securityService.authorizeClusterRead();
+    this.securityService.authorizeClusterRead();
 
     try {
       CqService cqService = crHelper.getCache().getCqService();
@@ -93,11 +90,13 @@ public class MonitorCQ extends BaseCQCommand {
     } catch (CqException cqe) {
       sendCqResponse(MessageType.CQ_EXCEPTION_TYPE, "", clientMessage.getTransactionId(), cqe,
           serverConnection);
+      return;
     } catch (Exception e) {
       String err = LocalizedStrings.MonitorCQ_EXCEPTION_WHILE_HANDLING_THE_MONITOR_REQUEST_OP_IS_0
-          .toLocalizedString(op);
+          .toLocalizedString(Integer.valueOf(op));
       sendCqResponse(MessageType.CQ_EXCEPTION_TYPE, err, clientMessage.getTransactionId(), e,
           serverConnection);
+      return;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/StopCQ.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/StopCQ.java b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/StopCQ.java
index a3d51ed..99fbef1 100644
--- a/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/StopCQ.java
+++ b/geode-cq/src/main/java/org/apache/geode/internal/cache/tier/sockets/command/StopCQ.java
@@ -14,7 +14,12 @@
  */
 package org.apache.geode.internal.cache.tier.sockets.command;
 
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.geode.cache.query.CqException;
+import org.apache.geode.cache.query.internal.cq.CqQueryImpl;
 import org.apache.geode.cache.query.internal.cq.CqService;
 import org.apache.geode.cache.query.internal.cq.InternalCqQuery;
 import org.apache.geode.distributed.internal.DistributionStats;
@@ -27,31 +32,26 @@ import org.apache.geode.internal.cache.tier.sockets.Message;
 import org.apache.geode.internal.cache.tier.sockets.ServerConnection;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.security.AuthorizeRequest;
-import org.apache.geode.internal.security.SecurityService;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
 
 public class StopCQ extends BaseCQCommand {
 
-  private static final StopCQ singleton = new StopCQ();
+  private final static StopCQ singleton = new StopCQ();
 
   public static Command getCommand() {
     return singleton;
   }
 
-  private StopCQ() {
-    // nothing
-  }
+  private StopCQ() {}
 
   @Override
-  public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection,
-      final SecurityService securityService, long start) throws IOException {
+  public void cmdExecute(Message clientMessage, ServerConnection serverConnection, long start)
+      throws IOException {
     CachedRegionHelper crHelper = serverConnection.getCachedRegionHelper();
     ClientProxyMembershipID id = serverConnection.getProxyID();
     CacheServerStats stats = serverConnection.getCacheServerStats();
 
+    // Based on MessageType.QUERY
+    // Added by Rao 2/1/2007
     serverConnection.setAsTrue(REQUIRES_RESPONSE);
     serverConnection.setAsTrue(REQUIRES_CHUNKED_RESPONSE);
 
@@ -86,7 +86,7 @@ public class StopCQ extends BaseCQCommand {
       }
       InternalCqQuery cqQuery = cqService.getCq(serverCqName);
 
-      securityService.authorizeDataManage();
+      this.securityService.authorizeDataManage();
 
       AuthorizeRequest authzRequest = serverConnection.getAuthzRequest();
       if (authzRequest != null) {
@@ -96,7 +96,7 @@ public class StopCQ extends BaseCQCommand {
         if (cqQuery != null) {
           queryStr = cqQuery.getQueryString();
           cqRegionNames = new HashSet();
-          cqRegionNames.add(cqQuery.getRegionName());
+          cqRegionNames.add(((CqQueryImpl) cqQuery).getRegionName());
         }
         authzRequest.stopCQAuthorize(cqName, queryStr, cqRegionNames);
       }
@@ -122,9 +122,12 @@ public class StopCQ extends BaseCQCommand {
 
     serverConnection.setAsTrue(RESPONDED);
 
-    long oldStart = start;
-    start = DistributionStats.getStatTime();
-    stats.incProcessStopCqTime(start - oldStart);
+    {
+      long oldStart = start;
+      start = DistributionStats.getStatTime();
+      stats.incProcessStopCqTime(start - oldStart);
+    }
+
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-cq/src/test/java/org/apache/geode/security/CQPDXPostProcessorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/org/apache/geode/security/CQPDXPostProcessorDUnitTest.java b/geode-cq/src/test/java/org/apache/geode/security/CQPDXPostProcessorDUnitTest.java
index c38bd3b..2489b95 100644
--- a/geode-cq/src/test/java/org/apache/geode/security/CQPDXPostProcessorDUnitTest.java
+++ b/geode-cq/src/test/java/org/apache/geode/security/CQPDXPostProcessorDUnitTest.java
@@ -128,7 +128,7 @@ public class CQPDXPostProcessorDUnitTest extends JUnit4DistributedTestCase {
     // wait for events to fire
     Awaitility.await().atMost(1, TimeUnit.SECONDS);
     PDXPostProcessor pp =
-        (PDXPostProcessor) server.getCache().getSecurityService().getPostProcessor();
+        (PDXPostProcessor) SecurityService.getSecurityService().getPostProcessor();
     assertEquals(pp.getCount(), 2);
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-cq/src/test/java/org/apache/geode/security/ClientAuthzObjectModDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/org/apache/geode/security/ClientAuthzObjectModDUnitTest.java b/geode-cq/src/test/java/org/apache/geode/security/ClientAuthzObjectModDUnitTest.java
index a8ab8f9..dd50467 100755
--- a/geode-cq/src/test/java/org/apache/geode/security/ClientAuthzObjectModDUnitTest.java
+++ b/geode-cq/src/test/java/org/apache/geode/security/ClientAuthzObjectModDUnitTest.java
@@ -14,9 +14,6 @@
  */
 package org.apache.geode.security;
 
-import static org.apache.geode.security.SecurityTestUtils.closeCache;
-import static org.apache.geode.security.SecurityTestUtils.getLocatorPort;
-
 import org.apache.geode.DataSerializable;
 import org.apache.geode.Instantiator;
 import org.apache.geode.cache.operations.OperationContext.OperationCode;
@@ -40,6 +37,9 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Random;
 
+import static org.apache.geode.security.SecurityTestUtils.closeCache;
+import static org.apache.geode.security.SecurityTestUtils.getLocatorPort;
+
 /**
  * Tests for authorization callback that modify objects and callbacks from client to server.
  * 
@@ -57,10 +57,8 @@ import java.util.Random;
 @Category({DistributedTest.class, SecurityTest.class})
 public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestCase {
 
-  private static final String PRE_ACCESSOR_CREATE =
-      FilterPreAuthorization.class.getName() + ".create";
-  private static final String POST_ACCESSOR_CREATE =
-      FilterPostAuthorization.class.getName() + ".create";
+  private static final String preAccessor = FilterPreAuthorization.class.getName() + ".create";
+  private static final String postAccessor = FilterPostAuthorization.class.getName() + ".create";
 
   @Override
   protected final void postSetUpClientAuthorizationTestBase() throws Exception {
@@ -90,14 +88,13 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestCase {
 
     System.out.println("testPutsGetsObjectModWithFailover: Using authinit: " + authInit);
     System.out.println("testPutsGetsObjectModWithFailover: Using authenticator: " + authenticator);
+    System.out
+        .println("testPutsGetsObjectModWithFailover: Using pre-operation accessor: " + preAccessor);
     System.out.println(
-        "testPutsGetsObjectModWithFailover: Using pre-operation accessor: " + PRE_ACCESSOR_CREATE);
-    System.out.println("testPutsGetsObjectModWithFailover: Using post-operation accessor: "
-        + POST_ACCESSOR_CREATE);
+        "testPutsGetsObjectModWithFailover: Using post-operation accessor: " + postAccessor);
 
     // Start servers with all required properties
-    Properties serverProps =
-        buildProperties(authenticator, extraProps, PRE_ACCESSOR_CREATE, POST_ACCESSOR_CREATE);
+    Properties serverProps = buildProperties(authenticator, extraProps, preAccessor, postAccessor);
 
     // Get ports for the servers
     int[] portsList = AvailablePortHelper.getRandomAvailableTCPPorts(2);
@@ -252,6 +249,7 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestCase {
         OperationWithAction.OPBLOCK_END};
   }
 
+
   private Properties buildProperties(final String authenticator, final Properties extraProps,
       final String preAccessor, final String postAccessor) {
     Properties authProps = new Properties();

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
index 5252bd1..da0dfa2 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
@@ -29,6 +29,8 @@ import org.apache.geode.cache.lucene.internal.cli.functions.LuceneSearchIndexFun
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.execute.AbstractExecution;
+import org.apache.geode.internal.security.IntegratedSecurityService;
+import org.apache.geode.internal.security.SecurityService;
 import org.apache.geode.management.cli.CliMetaData;
 import org.apache.geode.management.cli.ConverterHint;
 import org.apache.geode.management.cli.Result;
@@ -78,6 +80,8 @@ public class LuceneIndexCommands implements GfshCommand {
       new LuceneDestroyIndexFunction();
   private List<LuceneSearchResults> searchResults = null;
 
+  private SecurityService securityService = IntegratedSecurityService.getSecurityService();
+
   @CliCommand(value = LuceneCliStrings.LUCENE_LIST_INDEX,
       help = LuceneCliStrings.LUCENE_LIST_INDEX__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
@@ -178,7 +182,7 @@ public class LuceneIndexCommands implements GfshCommand {
     Result result;
     XmlEntity xmlEntity = null;
 
-    getCache().getSecurityService().authorizeRegionManage(regionPath);
+    this.securityService.authorizeRegionManage(regionPath);
     try {
       final InternalCache cache = getCache();
       // trim fields for any leading trailing spaces.
@@ -324,7 +328,7 @@ public class LuceneIndexCommands implements GfshCommand {
           CliStrings.format(LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__INDEX_CANNOT_BE_EMPTY));
     }
 
-    getCache().getSecurityService().authorizeRegionManage(regionPath);
+    this.securityService.authorizeRegionManage(regionPath);
 
     Result result;
     try {

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
index 1adab5a..8deac25 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
@@ -37,7 +37,6 @@ import org.apache.geode.cache.lucene.internal.cli.functions.LuceneListIndexFunct
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.execute.AbstractExecution;
-import org.apache.geode.internal.security.SecurityService;
 import org.apache.geode.internal.util.CollectionUtils;
 import org.apache.geode.management.cli.Result.Status;
 import org.apache.geode.management.internal.cli.functions.CliFunctionResult;
@@ -51,7 +50,6 @@ import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.core.KeywordAnalyzer;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.junit.Assert;
-import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -87,16 +85,9 @@ import junitparams.Parameters;
 @RunWith(JUnitParamsRunner.class)
 public class LuceneIndexCommandsJUnitTest {
 
-  private InternalCache mockCache;
-
-  @Before
-  public void before() throws Exception {
-    this.mockCache = mock(InternalCache.class, "InternalCache");
-    when(this.mockCache.getSecurityService()).thenReturn(mock(SecurityService.class));
-  }
-
   @Test
-  public void testListIndexWithoutStats() throws Exception {
+  public void testListIndexWithoutStats() {
+    final InternalCache mockCache = mock(InternalCache.class, "InternalCache");
     final String serverName = "mockServer";
     final AbstractExecution mockFunctionExecutor =
         mock(AbstractExecution.class, "Function Executor");
@@ -122,7 +113,7 @@ public class LuceneIndexCommandsJUnitTest {
         .thenReturn(mockResultCollector);
     when(mockResultCollector.getResult()).thenReturn(results);
 
-    final LuceneIndexCommands commands = createIndexCommands(this.mockCache, mockFunctionExecutor);
+    final LuceneIndexCommands commands = createIndexCommands(mockCache, mockFunctionExecutor);
 
     CommandResult result = (CommandResult) commands.listIndex(false);
     TabularResultData data = (TabularResultData) result.getResultData();
@@ -142,7 +133,8 @@ public class LuceneIndexCommandsJUnitTest {
   }
 
   @Test
-  public void testListIndexWithStats() throws Exception {
+  public void testListIndexWithStats() {
+    final InternalCache mockCache = mock(InternalCache.class, "InternalCache");
     final String serverName = "mockServer";
     final AbstractExecution mockFunctionExecutor =
         mock(AbstractExecution.class, "Function Executor");
@@ -170,7 +162,7 @@ public class LuceneIndexCommandsJUnitTest {
         .thenReturn(mockResultCollector);
     when(mockResultCollector.getResult()).thenReturn(results);
 
-    final LuceneIndexCommands commands = createIndexCommands(this.mockCache, mockFunctionExecutor);
+    final LuceneIndexCommands commands = createIndexCommands(mockCache, mockFunctionExecutor);
 
     CommandResult result = (CommandResult) commands.listIndex(true);
     TabularResultData data = (TabularResultData) result.getResultData();
@@ -193,8 +185,9 @@ public class LuceneIndexCommandsJUnitTest {
 
   @Test
   public void testCreateIndex() throws Exception {
+    final InternalCache mockCache = mock(InternalCache.class);
     final ResultCollector mockResultCollector = mock(ResultCollector.class);
-    final LuceneIndexCommands commands = spy(createIndexCommands(this.mockCache, null));
+    final LuceneIndexCommands commands = spy(createIndexCommands(mockCache, null));
 
     final List<CliFunctionResult> cliFunctionResults = new ArrayList<>();
     cliFunctionResults.add(new CliFunctionResult("member1", true, "Index Created"));
@@ -222,9 +215,10 @@ public class LuceneIndexCommandsJUnitTest {
 
   @Test
   public void testDescribeIndex() throws Exception {
+    final InternalCache mockCache = mock(InternalCache.class, "InternalCache");
     final String serverName = "mockServer";
     final ResultCollector mockResultCollector = mock(ResultCollector.class, "ResultCollector");
-    final LuceneIndexCommands commands = spy(createIndexCommands(this.mockCache, null));
+    final LuceneIndexCommands commands = spy(createIndexCommands(mockCache, null));
 
     String[] searchableFields = {"field1", "field2", "field3"};
     Map<String, Analyzer> fieldAnalyzers = new HashMap<>();
@@ -258,8 +252,9 @@ public class LuceneIndexCommandsJUnitTest {
 
   @Test
   public void testSearchIndex() throws Exception {
+    final InternalCache mockCache = mock(InternalCache.class, "InternalCache");
     final ResultCollector mockResultCollector = mock(ResultCollector.class, "ResultCollector");
-    final LuceneIndexCommands commands = spy(createIndexCommands(this.mockCache, null));
+    final LuceneIndexCommands commands = spy(createIndexCommands(mockCache, null));
 
     final List<Set<LuceneSearchResults>> queryResultsList = new ArrayList<>();
     HashSet<LuceneSearchResults> queryResults = new HashSet<>();
@@ -282,9 +277,10 @@ public class LuceneIndexCommandsJUnitTest {
 
   @Ignore
   public void testSearchIndexWithPaging() throws Exception {
+    final InternalCache mockCache = mock(InternalCache.class, "InternalCache");
     final Gfsh mockGfsh = mock(Gfsh.class);
     final ResultCollector mockResultCollector = mock(ResultCollector.class, "ResultCollector");
-    final LuceneIndexCommands commands = spy(createIndexCommands(this.mockCache, null));
+    final LuceneIndexCommands commands = spy(createIndexCommands(mockCache, null));
     ArgumentCaptor<String> resultCaptor = ArgumentCaptor.forClass(String.class);
 
     LuceneSearchResults result1 = createQueryResults("A", "Result1", Float.valueOf("1.7"));
@@ -349,8 +345,9 @@ public class LuceneIndexCommandsJUnitTest {
 
   @Test
   public void testSearchIndexWithKeysOnly() throws Exception {
+    final InternalCache mockCache = mock(InternalCache.class, "InternalCache");
     final ResultCollector mockResultCollector = mock(ResultCollector.class, "ResultCollector");
-    final LuceneIndexCommands commands = spy(createIndexCommands(this.mockCache, null));
+    final LuceneIndexCommands commands = spy(createIndexCommands(mockCache, null));
 
     final List<Set<LuceneSearchResults>> queryResultsList = new ArrayList<>();
     HashSet<LuceneSearchResults> queryResults = new HashSet<>();
@@ -371,8 +368,9 @@ public class LuceneIndexCommandsJUnitTest {
 
   @Test
   public void testSearchIndexWhenSearchResultsHaveSameScore() throws Exception {
+    final InternalCache mockCache = mock(InternalCache.class, "InternalCache");
     final ResultCollector mockResultCollector = mock(ResultCollector.class, "ResultCollector");
-    final LuceneIndexCommands commands = spy(createIndexCommands(this.mockCache, null));
+    final LuceneIndexCommands commands = spy(createIndexCommands(mockCache, null));
 
     final List<Set<LuceneSearchResults>> queryResultsList = new ArrayList<>();
     HashSet<LuceneSearchResults> queryResults = new HashSet<>();
@@ -547,8 +545,9 @@ public class LuceneIndexCommandsJUnitTest {
   }
 
   private LuceneIndexCommands createTestLuceneIndexCommandsForDestroyIndex() {
+    final InternalCache mockCache = mock(InternalCache.class);
     final ResultCollector mockResultCollector = mock(ResultCollector.class);
-    final LuceneIndexCommands commands = spy(createIndexCommands(this.mockCache, null));
+    final LuceneIndexCommands commands = spy(createIndexCommands(mockCache, null));
 
     final List<CliFunctionResult> cliFunctionResults = new ArrayList<>();
     cliFunctionResults.add(new CliFunctionResult("member", true, "Index Destroyed"));
@@ -657,7 +656,7 @@ public class LuceneIndexCommandsJUnitTest {
     @Override
     public Execution getMembersFunctionExecutor(final Set<DistributedMember> members) {
       Assert.assertNotNull(members);
-      return this.functionExecutor;
+      return functionExecutor;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
index 63f907c..087aff4 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
@@ -1,4 +1,5 @@
 /*
+ *
  * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
  * agreements. See the NOTICE file distributed with this work for additional information regarding
  * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
@@ -11,33 +12,20 @@
  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
+ *
  */
 package org.apache.geode.tools.pulse.tests;
 
-import org.apache.geode.internal.security.SecurityService;
-import org.apache.geode.internal.security.SecurityServiceFactory;
-import org.apache.geode.internal.security.shiro.CustomAuthRealm;
-import org.apache.geode.internal.security.shiro.JMXShiroAuthenticator;
-import org.apache.geode.management.internal.security.AccessControlMBean;
-import org.apache.geode.management.internal.security.MBeanServerWrapper;
-import org.apache.geode.management.internal.security.ResourceConstants;
-import org.apache.geode.security.TestSecurityManager;
-import org.apache.geode.tools.pulse.internal.data.PulseConstants;
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.mgt.DefaultSecurityManager;
-import org.apache.shiro.mgt.SecurityManager;
-import org.apache.shiro.realm.Realm;
-
 import java.io.IOException;
 import java.lang.management.ManagementFactory;
 import java.net.Inet4Address;
 import java.net.Inet6Address;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
-import java.rmi.registry.LocateRegistry;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
+
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.MBeanRegistrationException;
 import javax.management.MBeanServer;
@@ -48,6 +36,19 @@ import javax.management.remote.JMXConnectorServer;
 import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXServiceURL;
 
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.security.TestSecurityManager;
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.mgt.DefaultSecurityManager;
+import org.apache.shiro.mgt.SecurityManager;
+import org.apache.shiro.realm.Realm;
+
+import org.apache.geode.internal.security.shiro.CustomAuthRealm;
+import org.apache.geode.internal.security.shiro.JMXShiroAuthenticator;
+import org.apache.geode.management.internal.security.AccessControlMBean;
+import org.apache.geode.management.internal.security.MBeanServerWrapper;
+import org.apache.geode.management.internal.security.ResourceConstants;
+
 public class Server {
 
   private static final String DEFAULT_HOST = "127.0.0.1"; // "localhost"
@@ -78,20 +79,16 @@ public class Server {
       SecurityUtils.setSecurityManager(securityManager);
 
       // register the AccessControll bean
-      AccessControlMBean acc = new AccessControlMBean(SecurityServiceFactory.create());
+      AccessControlMBean acc = new AccessControlMBean();
       ObjectName accessControlMBeanON = new ObjectName(ResourceConstants.OBJECT_NAME_ACCESSCONTROL);
       MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
       platformMBeanServer.registerMBean(acc, accessControlMBeanON);
 
-      SecurityService securityService =
-          SecurityServiceFactory.create(securityProperties, new TestSecurityManager(), null);
-      securityService.initSecurity(securityProperties);
-
       // wire in the authenticator and authorizaton
-      JMXShiroAuthenticator interceptor = new JMXShiroAuthenticator(securityService);
+      JMXShiroAuthenticator interceptor = new JMXShiroAuthenticator();
       env.put(JMXConnectorServer.AUTHENTICATOR, interceptor);
       cs = JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
-      cs.setMBeanServerForwarder(new MBeanServerWrapper(securityService));
+      cs.setMBeanServerForwarder(new MBeanServerWrapper());
 
       // set up the AccessControlMXBean
 
@@ -101,7 +98,7 @@ public class Server {
     }
 
     try {
-      LocateRegistry.createRegistry(jmxPort);
+      java.rmi.registry.LocateRegistry.createRegistry(jmxPort);
       System.out.println("RMI registry ready.");
     } catch (Exception e) {
       System.out.println("Exception starting RMI registry:");

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java
index 767588d..3183f87 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/ServerRule.java
@@ -11,10 +11,12 @@
  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
+ *
  */
+
 package org.apache.geode.tools.pulse.tests.rules;
 
-import org.apache.geode.internal.security.DisabledSecurityService;
+
 import org.apache.geode.tools.pulse.internal.data.PulseConstants;
 import org.awaitility.Awaitility;
 import org.apache.geode.internal.AvailablePort;

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-rebalancer/src/main/java/org/apache/geode/cache/util/AutoBalancer.java
----------------------------------------------------------------------
diff --git a/geode-rebalancer/src/main/java/org/apache/geode/cache/util/AutoBalancer.java b/geode-rebalancer/src/main/java/org/apache/geode/cache/util/AutoBalancer.java
index 3eced02..0f1a995 100644
--- a/geode-rebalancer/src/main/java/org/apache/geode/cache/util/AutoBalancer.java
+++ b/geode-rebalancer/src/main/java/org/apache/geode/cache/util/AutoBalancer.java
@@ -53,9 +53,9 @@ import org.apache.geode.internal.logging.LogService;
  * re-balancing request. Auto-Balancing is expected to prevent failures and data loss.
  * 
  * <P>
- * This implementation is based on {@code ConfigInitialization} implementation. By default
- * auto-balancing is disabled. A user needs to configure {@link AutoBalancer} during cache
- * initialization {@link GemFireCache#getInitializer()}
+ * This implementation is based on {@code Initializer} implementation. By default auto-balancing is
+ * disabled. A user needs to configure {@link AutoBalancer} during cache initialization
+ * {@link GemFireCache#getInitializer()}
  * 
  * <P>
  * In a cluster only one member owns auto-balancing responsibility. This is achieved by grabbing a

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/GeodeAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/GeodeAuthenticationProvider.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/GeodeAuthenticationProvider.java
index 2f307c9..06c0fb1 100644
--- a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/GeodeAuthenticationProvider.java
+++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/GeodeAuthenticationProvider.java
@@ -16,10 +16,7 @@
 
 package org.apache.geode.rest.internal.web.security;
 
-import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.security.SecurityService;
-import org.apache.geode.internal.security.SecurityServiceFactory;
 import org.apache.geode.management.internal.security.ResourceConstants;
 import org.apache.geode.security.GemFireSecurityException;
 import org.springframework.security.authentication.AuthenticationProvider;
@@ -35,26 +32,7 @@ import java.util.Properties;
 
 @Component
 public class GeodeAuthenticationProvider implements AuthenticationProvider {
-
-  private final SecurityService securityService;
-
-  public GeodeAuthenticationProvider() {
-    // TODO: can we pass SecurityService in?
-    this.securityService = findSecurityService();
-  }
-
-  private static SecurityService findSecurityService() {
-    InternalCache cache = GemFireCacheImpl.getInstance();
-    if (cache != null) {
-      return cache.getSecurityService();
-    } else {
-      return SecurityServiceFactory.create();
-    }
-  }
-
-  public SecurityService getSecurityService() {
-    return this.securityService;
-  }
+  private SecurityService securityService = SecurityService.getSecurityService();
 
   @Override
   public Authentication authenticate(Authentication authentication) throws AuthenticationException {

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityConfiguration.java
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityConfiguration.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityConfiguration.java
index ba6970a..f0491b7 100644
--- a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityConfiguration.java
+++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityConfiguration.java
@@ -11,9 +11,12 @@
  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
+ *
  */
 package org.apache.geode.rest.internal.web.security;
 
+import org.apache.geode.internal.security.IntegratedSecurityService;
+import org.apache.geode.internal.security.SecurityService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
@@ -32,6 +35,8 @@ import org.springframework.security.config.http.SessionCreationPolicy;
 @ComponentScan("org.apache.geode.rest.internal.web")
 public class RestSecurityConfiguration extends WebSecurityConfigurerAdapter {
 
+  private SecurityService securityService = IntegratedSecurityService.getSecurityService();
+
   @Autowired
   private GeodeAuthenticationProvider authProvider;
 
@@ -53,7 +58,7 @@ public class RestSecurityConfiguration extends WebSecurityConfigurerAdapter {
             "/webjars/springfox-swagger-ui/**", "/swagger-resources/**")
         .permitAll().anyRequest().authenticated().and().csrf().disable();
 
-    if (this.authProvider.getSecurityService().isIntegratedSecurity()) {
+    if (securityService.isIntegratedSecurity()) {
       http.httpBasic();
     } else {
       http.authorizeRequests().anyRequest().permitAll();

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityService.java
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityService.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityService.java
index 6d66947..80ff719 100644
--- a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityService.java
+++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/security/RestSecurityService.java
@@ -12,28 +12,16 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
+
 package org.apache.geode.rest.internal.web.security;
 
-import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.security.SecurityService;
-import org.apache.geode.internal.security.SecurityServiceFactory;
 import org.apache.geode.security.GemFireSecurityException;
 import org.springframework.stereotype.Component;
 
 @Component("securityService")
 public class RestSecurityService {
-
-  private final SecurityService securityService;
-
-  public RestSecurityService() {
-    InternalCache cache = GemFireCacheImpl.getInstance();
-    if (cache != null) {
-      this.securityService = cache.getSecurityService();
-    } else {
-      this.securityService = SecurityServiceFactory.create();
-    }
-  }
+  private SecurityService securityService = SecurityService.getSecurityService();
 
   public boolean authorize(String resource, String operation) {
     return authorize(resource, operation, null, null);

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/DataCommandsOverHttpDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/DataCommandsOverHttpDistributedTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/DataCommandsOverHttpDistributedTest.java
new file mode 100644
index 0000000..98a9434
--- /dev/null
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/DataCommandsOverHttpDistributedTest.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.management.internal.cli.commands;
+
+import static org.apache.geode.test.dunit.LogWriterUtils.*;
+import static org.apache.geode.test.dunit.Wait.*;
+import static org.junit.Assert.*;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionFactory;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.management.DistributedRegionMXBean;
+import org.apache.geode.management.ManagementService;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.result.CommandResult;
+import org.apache.geode.test.dunit.Host;
+import org.apache.geode.test.dunit.SerializableRunnable;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.WaitCriterion;
+import org.apache.geode.test.junit.categories.DistributedTest;
+
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.ProvideSystemProperty;
+import org.junit.experimental.categories.Category;
+
+@Category(DistributedTest.class)
+@SuppressWarnings("deprecated")
+public class DataCommandsOverHttpDistributedTest extends CliCommandTestBase {
+
+  private static final String REBALANCE_REGION_NAME =
+      DataCommandsOverHttpDistributedTest.class.getSimpleName() + "Region";
+
+  @ClassRule
+  public static ProvideSystemProperty provideSystemProperty =
+      new ProvideSystemProperty(CliCommandTestBase.USE_HTTP_SYSTEM_PROPERTY, "true");
+
+  @Test
+  public void testSimulateForEntireDSWithTimeout() {
+    setupTestRebalanceForEntireDS();
+    // check if DistributedRegionMXBean is available so that command will not fail
+    final VM manager = Host.getHost(0).getVM(0);
+    manager.invoke(checkRegionMBeans);
+
+    getLogWriter().info("testSimulateForEntireDS verified MBean and executing command");
+
+    String command = "rebalance --simulate=true --time-out=-1";
+
+    CommandResult cmdResult = executeCommand(command);
+
+    getLogWriter().info("testSimulateForEntireDS just after executing " + cmdResult);
+
+    if (cmdResult != null) {
+      String stringResult = commandResultToString(cmdResult);
+      getLogWriter().info("testSimulateForEntireDS stringResult : " + stringResult);
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+    } else {
+      fail("testRebalanceForIncludeRegionFunction failed as did not get CommandResult");
+    }
+  }
+
+  SerializableRunnable checkRegionMBeans = new SerializableRunnable() {
+    @Override
+    public void run() {
+      final WaitCriterion waitForMaangerMBean = new WaitCriterion() {
+        @Override
+        public boolean done() {
+          final ManagementService service = ManagementService.getManagementService(getCache());
+          final DistributedRegionMXBean bean =
+              service.getDistributedRegionMXBean(Region.SEPARATOR + REBALANCE_REGION_NAME);
+          if (bean == null) {
+            getLogWriter().info("Still probing for checkRegionMBeans ManagerMBean");
+            return false;
+          } else {
+            // verify that bean is proper before executing tests
+            if (bean.getMembers() != null && bean.getMembers().length > 1
+                && bean.getMemberCount() > 0
+                && service.getDistributedSystemMXBean().listRegions().length >= 2) {
+              return true;
+            } else {
+              return false;
+            }
+          }
+        }
+
+        @Override
+        public String description() {
+          return "Probing for testRebalanceCommandForSimulateWithNoMember ManagerMBean";
+        }
+      };
+      waitForCriterion(waitForMaangerMBean, 2 * 60 * 1000, 2000, true);
+      DistributedRegionMXBean bean = ManagementService.getManagementService(getCache())
+          .getDistributedRegionMXBean("/" + REBALANCE_REGION_NAME);
+      assertNotNull(bean);
+    }
+  };
+
+  void setupTestRebalanceForEntireDS() {
+    final VM vm1 = Host.getHost(0).getVM(1);
+    final VM vm2 = Host.getHost(0).getVM(2);
+    setUpJmxManagerOnVm0ThenConnect(null);
+
+    vm1.invoke(new SerializableRunnable() {
+      public void run() {
+
+        // no need to close cache as it will be closed as part of teardown2
+        Cache cache = getCache();
+
+        RegionFactory<Integer, Integer> dataRegionFactory =
+            cache.createRegionFactory(RegionShortcut.PARTITION);
+        Region region = dataRegionFactory.create(REBALANCE_REGION_NAME);
+        for (int i = 0; i < 10; i++) {
+          region.put("key" + (i + 200), "value" + (i + 200));
+        }
+        region = dataRegionFactory.create(REBALANCE_REGION_NAME + "Another1");
+        for (int i = 0; i < 100; i++) {
+          region.put("key" + (i + 200), "value" + (i + 200));
+        }
+      }
+    });
+
+    vm2.invoke(new SerializableRunnable() {
+      public void run() {
+
+        // no need to close cache as it will be closed as part of teardown2
+        Cache cache = getCache();
+
+        RegionFactory<Integer, Integer> dataRegionFactory =
+            cache.createRegionFactory(RegionShortcut.PARTITION);
+        Region region = dataRegionFactory.create(REBALANCE_REGION_NAME);
+        for (int i = 0; i < 100; i++) {
+          region.put("key" + (i + 400), "value" + (i + 400));
+        }
+        region = dataRegionFactory.create(REBALANCE_REGION_NAME + "Another2");
+        for (int i = 0; i < 10; i++) {
+          region.put("key" + (i + 200), "value" + (i + 200));
+        }
+      }
+    });
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandOverHttpDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandOverHttpDistributedTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandOverHttpDistributedTest.java
deleted file mode 100644
index 6101744..0000000
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/RebalanceCommandOverHttpDistributedTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.commands;
-
-import org.apache.geode.test.junit.categories.DistributedTest;
-import org.junit.ClassRule;
-import org.junit.contrib.java.lang.system.ProvideSystemProperty;
-import org.junit.experimental.categories.Category;
-
-@Category(DistributedTest.class)
-@SuppressWarnings("deprecated")
-public class RebalanceCommandOverHttpDistributedTest extends RebalanceCommandDistributedTest {
-
-  @ClassRule
-  public static ProvideSystemProperty provideSystemProperty =
-      new ProvideSystemProperty(CliCommandTestBase.USE_HTTP_SYSTEM_PROPERTY, "true");
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/fd638d52/geode-web/src/test/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptorRequestHeaderJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptorRequestHeaderJUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptorRequestHeaderJUnitTest.java
index a58bcba..00156cd 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptorRequestHeaderJUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/web/controllers/support/LoginHandlerInterceptorRequestHeaderJUnitTest.java
@@ -41,7 +41,8 @@ public class LoginHandlerInterceptorRequestHeaderJUnitTest {
   public void before() {
     LoginHandlerInterceptor.getEnvironment().clear();
     securityService = Mockito.mock(SecurityService.class);
-    interceptor = new LoginHandlerInterceptor(securityService);
+    interceptor = new LoginHandlerInterceptor();
+    interceptor.setSecurityService(securityService);
   }
 
   @After


Mime
View raw message