You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by zh...@apache.org on 2017/06/27 05:00:16 UTC

[01/46] geode git commit: GEODE-3071: Provide capability to parallelize distributedTests [Forced Update!]

Repository: geode
Updated Branches:
  refs/heads/feature/GEM-1483 8b629d356 -> 1ef7d2b6a (forced update)


GEODE-3071: Provide capability to parallelize distributedTests

Herewith the ability to leverage Gradle's parallel test execution
capability to run dunits in parallel. This is combined with launching
tests in Docker containers to provide process, network and filesystem
isolation. Depending on the size of your system, this can speed up
running the distributedTest task 2-5 times.

The capability is enabled by launching gradle with '-PparallelDunit'

Tunables, enabled as gradle parametrs (-P option) are:

- dunitDockerImage: The docker image which will be used to launch
  tests. The image must have the JAVA_HOME environment variable set. The
  image must be pulled locally before starting the tests.
- dunitParallelForks: The number of parallel docker containers to be
  launched.
- dunitDockerUser: The docker user which will run the tests. Because of
  the way that the containers map the build directory into them, the
  test artifacts, will be written with this user id. By default this is
  'root'.


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

Branch: refs/heads/feature/GEM-1483
Commit: 588c3ed8af4b9a1b46737c2faebafa589a396e12
Parents: a4d790c
Author: Jens Deppe <jd...@pivotal.io>
Authored: Wed Jun 14 08:03:22 2017 -0700
Committer: Jens Deppe <jd...@pivotal.io>
Committed: Wed Jun 14 08:03:22 2017 -0700

----------------------------------------------------------------------
 build.gradle         |  2 ++
 gradle.properties    |  7 ++++
 gradle/docker.gradle | 83 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 92 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/588c3ed8/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index ec6b920..57372b3 100755
--- a/build.gradle
+++ b/build.gradle
@@ -26,6 +26,7 @@ buildscript {
     classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.0.1'
     classpath "com.diffplug.gradle.spotless:spotless:2.2.0"
     classpath "me.champeau.gradle:jmh-gradle-plugin:0.3.1"
+    classpath "com.pedjak.gradle.plugins:dockerized-test:0.4.2"
   }
 }
 
@@ -82,6 +83,7 @@ apply from: "${scriptDir}/code-analysis.gradle"
 apply from: "${scriptDir}/sonar.gradle"
 apply from: "${scriptDir}/ide.gradle"
 apply from: "${scriptDir}/rat.gradle"
+apply from: "${scriptDir}/docker.gradle"
 
 subprojects {
   // Make sure clean task for rootProject runs last

http://git-wip-us.apache.org/repos/asf/geode/blob/588c3ed8/gradle.properties
----------------------------------------------------------------------
diff --git a/gradle.properties b/gradle.properties
index ca79a38..9462295 100755
--- a/gradle.properties
+++ b/gradle.properties
@@ -49,3 +49,10 @@ buildRoot=
 
 # We want signing to be on by default. Signing requires GPG to be set up.
 nexusSignArchives = true
+
+# Control how many concurrent dunit (using docker) tests will be run
+dunitParallelForks = 8
+# This is the name of the Docker image for running parallel dunits
+dunitDockerImage = openjdk:8
+# Docker user for parallel dunit tests
+dunitDockerUser = root

http://git-wip-us.apache.org/repos/asf/geode/blob/588c3ed8/gradle/docker.gradle
----------------------------------------------------------------------
diff --git a/gradle/docker.gradle b/gradle/docker.gradle
new file mode 100644
index 0000000..7a74c5d
--- /dev/null
+++ b/gradle/docker.gradle
@@ -0,0 +1,83 @@
+/*
+ * Configuration for running (dunit) tests in parallel in Docker containers.
+ * The container used must hava JAVA_HOME set in it's environment and must
+ * have 'java' defined on the path. For example, the relevant Dockerfile
+ * content could be:
+ * 
+ *   ENV JAVA_HOME=/opt/jdk1.8.0_u101
+ *   ENV PATH=$PATH:$JAVA_HOME/bin
+ *
+ * In addition, the container must have docker installed.
+ *
+ * The plugin can be activated with the Gradle property 'parallelDunit'.
+ * Additional properties that can be set are:
+ *
+ *  dunitDockerImage   - The docker image used for running parallel dunits. The
+ *                       default image is 'openjdk:8'. The image is required to
+ *                       have 'JAVA_HOME' set as an environment variable.
+ *  dunitParallelForks - The number of parallel containers that will be
+ *                       launched. The default is 8.
+ *  dunitDockerUser    - The user used within the docker container to run tests.
+ *                       The default is 'root'.
+ */
+
+def dockerConfig = {
+  maxParallelForks = dunitParallelForks.toInteger()
+
+  docker {
+    // base image for creating docker containers that execute the tests
+    image = dunitDockerImage
+
+    // volumes mounted to the containers
+    // in a form: host_dir : container_dir
+    def pwd = System.getenv('PWD')
+    def gradleHome = System.getenv('GRADLE_USER_HOME') ?: "${System.getenv('HOME')}/.gradle"
+    volumes = ["${gradleHome}":gradleHome]
+
+    volumes << ["${pwd}":pwd]
+
+    // specify the user for starting Gradle test worker within the container.
+    user = dunitDockerUser
+
+    argsInspect = { List args ->
+      def javaHomeIdx = 0
+      def i = args.iterator()
+      def j = 0
+      while (i.hasNext()) {
+        if (i.next() == '-e') {
+          def x = i.next()
+          j++
+          if (x.startsWith('JAVA_HOME')) {
+            javaHomeIdx = j
+          }
+        }
+        j++
+      }
+
+      // Remove JAVA_HOME env variable - it might not be the same as the container needs
+      if (javaHomeIdx > 0) {
+        args.removeAt(javaHomeIdx-1)
+        args.removeAt(javaHomeIdx-1)
+      }
+
+      // Infer the index of this invocation
+      def matcher = (args[args.size - 1] =~ /.*Executor (\d*).*/)
+
+      args[3] = args[3] + matcher[0][1]
+      def workdir = new File(args[3])
+      println "dockerize: making ${workdir}"
+      workdir.mkdirs()
+      // println args
+
+      args
+    }
+  }
+}
+
+subprojects {
+  apply plugin: 'com.github.pedjak.dockerized-test'
+
+  if (project.hasProperty('parallelDunit')) {
+    distributedTest.configure(dockerConfig)
+  }
+}


[33/46] geode git commit: GEODE-2995: incorporating even more review feedback

Posted by zh...@apache.org.
GEODE-2995: incorporating even more review feedback

Addressing feedback from Udo and Hitesh
Refactored test locations to match new src layout

Signed-off-by: Galen O'Sullivan <go...@pivotal.io>
Signed-off-by: Brian Rowe <br...@pivotal.io>


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

Branch: refs/heads/feature/GEM-1483
Commit: a3c66e1afc88700bd7839f56d54a0f6d44f00432
Parents: 0de1d97
Author: Brian Rowe <br...@pivotal.io>
Authored: Wed Jun 21 11:53:54 2017 -0700
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Mon Jun 26 09:26:22 2017 -0700

----------------------------------------------------------------------
 geode-protobuf/build.gradle                     |   6 +-
 .../protobuf/EncodingTypeTranslator.java        |  47 +++----
 .../operations/GetRequestOperationHandler.java  |  19 +--
 .../geode/client/protocol/IntegrationTest.java  | 124 -------------------
 .../geode/client/protocol/MessageUtil.java      |  41 ------
 .../geode/client/protocol/OpsHandler.java       |  21 ----
 .../geode/protocol/IntegrationJUnitTest.java    | 124 +++++++++++++++++++
 .../org/apache/geode/protocol/MessageUtil.java  |  41 ++++++
 .../org/apache/geode/protocol/OpsHandler.java   |  21 ++++
 .../GetRequestOperationHandlerTest.java         |  95 --------------
 ...eToSerializationTypeTranslatorJUnitTest.java |  73 +++++++++++
 .../protobuf/ProtobufOpsProcessorJUnitTest.java |  62 ++++++++++
 .../protobuf/ProtobufOpsProcessorTest.java      |  62 ----------
 .../GetRequestOperationHandlerJUnitTest.java    |  96 ++++++++++++++
 .../ProtobufProtocolSerializerJUnitTest.java    |   2 +-
 .../ProtobufSerializationServiceImplTest.java   |  58 ---------
 .../ProtobufSerializationServiceJUnitTest.java  | 111 +++++++++++++++++
 .../codec/BinaryFormatJUnitTest.java            |  64 ++++++++++
 .../codec/StringCodecJUnitTest.java             |  64 ----------
 ...eToSerializationTypeTranslatorJUnitTest.java |  73 -----------
 gradle/dependency-versions.properties           |   3 +
 21 files changed, 637 insertions(+), 570 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/build.gradle
----------------------------------------------------------------------
diff --git a/geode-protobuf/build.gradle b/geode-protobuf/build.gradle
index f069267..a63000e 100644
--- a/geode-protobuf/build.gradle
+++ b/geode-protobuf/build.gradle
@@ -23,7 +23,7 @@ buildscript {
         mavenCentral()
     }
     dependencies {
-        classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.1'
+        classpath 'com.google.protobuf:protobuf-gradle-plugin:' + project.'protobuf-gradle-plugin.version'
     }
 }
 
@@ -36,13 +36,13 @@ dependencies {
     testCompile 'org.powermock:powermock-module-junit4:' + project.'powermock.version'
     testCompile 'org.powermock:powermock-api-mockito:' + project.'powermock.version'
 
-    compile 'com.google.protobuf:protobuf-java:3.3.1'
+    compile 'com.google.protobuf:protobuf-java:' + project.'protobuf-java.version'
 }
 
 protobuf {
     protoc {
         // The artifact spec for the Protobuf Compiler
-        artifact = 'com.google.protobuf:protoc:3.0.0'
+        artifact = 'com.google.protobuf:protoc:' + project.'protoc.version'
     }
     generatedFilesBaseDir = "$buildDir/generated-src/proto"
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/EncodingTypeTranslator.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/EncodingTypeTranslator.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/EncodingTypeTranslator.java
index 650ac81..edb7c7e 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/EncodingTypeTranslator.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/EncodingTypeTranslator.java
@@ -20,10 +20,28 @@ import org.apache.geode.protocol.protobuf.BasicTypes;
 import org.apache.geode.serialization.SerializationType;
 import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
 
+import java.util.HashMap;
+
 /**
  * This class maps protobuf specific encoding types and the corresponding serialization types.
  */
 public abstract class EncodingTypeTranslator {
+  static final HashMap<Class, BasicTypes.EncodingType> typeToEncodingMap = intializeTypeMap();
+
+  private static HashMap<Class, BasicTypes.EncodingType> intializeTypeMap() {
+    HashMap<Class, BasicTypes.EncodingType> result = new HashMap<>();
+    result.put(Integer.class, BasicTypes.EncodingType.INT);
+    result.put(Byte.class, BasicTypes.EncodingType.BYTE);
+    result.put(Long.class, BasicTypes.EncodingType.LONG);
+    result.put(Float.class, BasicTypes.EncodingType.FLOAT);
+    result.put(Short.class, BasicTypes.EncodingType.SHORT);
+    result.put(byte[].class, BasicTypes.EncodingType.BINARY);
+    result.put(Double.class, BasicTypes.EncodingType.DOUBLE);
+    result.put(String.class, BasicTypes.EncodingType.STRING);
+    result.put(Boolean.class, BasicTypes.EncodingType.BOOLEAN);
+    return result;
+  }
+
   public static SerializationType getSerializationTypeForEncodingType(
       BasicTypes.EncodingType encodingType) throws UnsupportedEncodingTypeException {
     switch (encodingType) {
@@ -55,32 +73,19 @@ public abstract class EncodingTypeTranslator {
 
   public static BasicTypes.EncodingType getEncodingTypeForObject(Object resultValue)
       throws UnsupportedEncodingTypeException {
-    if (resultValue instanceof Integer) {
-      return BasicTypes.EncodingType.INT;
-    } else if (resultValue instanceof Byte) {
-      return BasicTypes.EncodingType.BYTE;
-    } else if (resultValue instanceof PdxInstance) {
+    if (resultValue instanceof PdxInstance) {
       String pdxClassName = ((PdxInstance) resultValue).getClassName();
       if (pdxClassName.equals(JSONFormatter.JSON_CLASSNAME)) {
         return BasicTypes.EncodingType.JSON;
       }
-    } else if (resultValue instanceof Long) {
-      return BasicTypes.EncodingType.LONG;
-    } else if (resultValue instanceof Float) {
-      return BasicTypes.EncodingType.FLOAT;
-    } else if (resultValue instanceof Short) {
-      return BasicTypes.EncodingType.SHORT;
-    } else if (resultValue instanceof byte[]) {
-      return BasicTypes.EncodingType.BINARY;
-    } else if (resultValue instanceof Double) {
-      return BasicTypes.EncodingType.DOUBLE;
-    } else if (resultValue instanceof String) {
-      return BasicTypes.EncodingType.STRING;
-    } else if (resultValue instanceof Boolean) {
-      return BasicTypes.EncodingType.BOOLEAN;
     }
 
-    throw new UnsupportedEncodingTypeException(
-        "We cannot translate: " + resultValue.getClass() + " into a specific Protobuf Encoding");
+    BasicTypes.EncodingType encodingType = typeToEncodingMap.get(resultValue.getClass());
+    if (encodingType == null) {
+      throw new UnsupportedEncodingTypeException(
+          "We cannot translate: " + resultValue.getClass() + " into a specific Protobuf Encoding");
+    } else {
+      return encodingType;
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandler.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandler.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandler.java
index 37d1d32..d9c1475 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandler.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandler.java
@@ -23,6 +23,7 @@ import org.apache.geode.protocol.protobuf.ClientProtocol;
 import org.apache.geode.protocol.protobuf.RegionAPI;
 import org.apache.geode.serialization.SerializationService;
 import org.apache.geode.protocol.protobuf.EncodingTypeTranslator;
+import org.apache.geode.serialization.exception.TypeEncodingException;
 import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
 import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
 
@@ -31,8 +32,7 @@ public class GetRequestOperationHandler
 
   @Override
   public RegionAPI.GetResponse process(SerializationService serializationService,
-      RegionAPI.GetRequest request, Cache cache)
-      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
+      RegionAPI.GetRequest request, Cache cache) throws TypeEncodingException {
     String regionName = request.getRegionName();
     BasicTypes.EncodedValue key = request.getKey();
     BasicTypes.EncodingType encodingType = key.getEncodingType();
@@ -42,6 +42,16 @@ public class GetRequestOperationHandler
     Region region = cache.getRegion(regionName);
     Object resultValue = region.get(decodedValue);
 
+    return buildGetResponse(serializationService, resultValue);
+  }
+
+  @Override
+  public int getOperationCode() {
+    return ClientProtocol.Request.RequestAPICase.GETREQUEST.getNumber();
+  }
+
+  private RegionAPI.GetResponse buildGetResponse(SerializationService serializationService,
+      Object resultValue) throws TypeEncodingException {
     BasicTypes.EncodingType resultEncodingType =
         EncodingTypeTranslator.getEncodingTypeForObject(resultValue);
     byte[] resultEncodedValue = serializationService.encode(resultEncodingType, resultValue);
@@ -50,9 +60,4 @@ public class GetRequestOperationHandler
         .setResult(ProtobufUtilities.getEncodedValue(resultEncodingType, resultEncodedValue))
         .build();
   }
-
-  @Override
-  public int getOperationCode() {
-    return ClientProtocol.Request.RequestAPICase.GETREQUEST.getNumber();
-  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java
deleted file mode 100644
index 63cde31..0000000
--- a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java
+++ /dev/null
@@ -1,124 +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.client.protocol;
-
-import com.google.protobuf.ByteString;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.Region;
-import org.apache.geode.protocol.protobuf.ProtobufStreamProcessor;
-import org.apache.geode.protocol.protobuf.BasicTypes;
-import org.apache.geode.protocol.protobuf.ClientProtocol;
-import org.apache.geode.protocol.protobuf.RegionAPI;
-import org.apache.geode.serialization.codec.StringCodec;
-import org.apache.geode.protocol.protobuf.EncodingTypeTranslator;
-import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
-import org.apache.geode.serialization.registry.SerializationCodecRegistry;
-import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
-import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
-import org.apache.geode.test.dunit.Assert;
-import org.apache.geode.test.junit.categories.UnitTest;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-@Category(UnitTest.class)
-public class IntegrationTest {
-
-  public static final String TEST_KEY = "my key";
-  public static final String TEST_VALUE = "my value";
-  public static final String TEST_REGION = "test region";
-  private StringCodec stringCodec;
-  private Cache cacheStub;
-  private Region regionStub;
-
-  @Before
-  public void setup() throws CodecAlreadyRegisteredForTypeException,
-      UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
-    SerializationCodecRegistry serializationCodecRegistry = new SerializationCodecRegistry();
-    stringCodec = (StringCodec) serializationCodecRegistry.getCodecForType(
-        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.STRING));
-    regionStub = getRegionStub();
-    cacheStub = getCacheStub(regionStub);
-  }
-
-  @Test
-  public void testGetRequestProcessed() throws Exception {
-    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-
-    ProtobufStreamProcessor streamProcessor = new ProtobufStreamProcessor();
-    streamProcessor.processOneMessage(getInputStream(getRequest(stringCodec)), outputStream,
-        cacheStub);
-
-    RegionAPI.GetResponse getResponse = getGetResponse(outputStream);
-
-    Assert.assertNotNull(getResponse);
-    Assert.assertEquals(BasicTypes.EncodingType.STRING, getResponse.getResult().getEncodingType());
-    String actualValue = stringCodec.decode(getResponse.getResult().getValue().toByteArray());
-    Assert.assertEquals(TEST_VALUE, actualValue);
-    verify(regionStub, times(1)).get(TEST_KEY);
-    verify(regionStub, times(1)).get(anyString());
-  }
-
-  private Region getRegionStub() {
-    regionStub = mock(Region.class);
-    when(regionStub.get(TEST_KEY)).thenReturn(TEST_VALUE);
-    return regionStub;
-  }
-
-  private Cache getCacheStub(Region region) {
-    Cache cacheStub = mock(Cache.class);
-    when(cacheStub.getRegion(TEST_REGION)).thenReturn(region);
-    return cacheStub;
-  }
-
-  private RegionAPI.GetResponse getGetResponse(ByteArrayOutputStream outputStream)
-      throws IOException {
-    ByteArrayInputStream helperInputStream = new ByteArrayInputStream(outputStream.toByteArray());
-    ClientProtocol.Message responseMessage =
-        ClientProtocol.Message.parseDelimitedFrom(helperInputStream);
-    ClientProtocol.Response response = responseMessage.getResponse();
-    return response.getGetResponse();
-  }
-
-  private ByteArrayInputStream getInputStream(ClientProtocol.Message request) throws IOException {
-    ByteArrayOutputStream helperOutputStream = new ByteArrayOutputStream();
-    request.writeDelimitedTo(helperOutputStream);
-    return new ByteArrayInputStream(helperOutputStream.toByteArray());
-  }
-
-  private ClientProtocol.Message getRequest(StringCodec stringCodec) {
-    RegionAPI.GetRequest.Builder getRequestBuilder = RegionAPI.GetRequest.newBuilder();
-    getRequestBuilder.setRegionName(TEST_REGION)
-        .setKey(BasicTypes.EncodedValue.newBuilder().setEncodingType(BasicTypes.EncodingType.STRING)
-            .setValue(ByteString.copyFrom(stringCodec.encode(TEST_KEY))));
-    ClientProtocol.Request request =
-        ClientProtocol.Request.newBuilder().setGetRequest(getRequestBuilder).build();
-    ClientProtocol.Message requestMessage = ClientProtocol.Message.newBuilder()
-        .setMessageHeader(ClientProtocol.MessageHeader.newBuilder()).setRequest(request).build();
-
-    return requestMessage;
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/MessageUtil.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/MessageUtil.java b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/MessageUtil.java
deleted file mode 100644
index c830b01..0000000
--- a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/MessageUtil.java
+++ /dev/null
@@ -1,41 +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.client.protocol;
-
-import org.apache.geode.protocol.protobuf.ClientProtocol;
-import org.apache.geode.protocol.protobuf.RegionAPI;
-
-public class MessageUtil {
-  public static ClientProtocol.Message createGetRequestMessage() {
-    ClientProtocol.Message.Builder messageBuilder = ClientProtocol.Message.newBuilder();
-    messageBuilder.setMessageHeader(getMessageHeaderBuilder());
-    ClientProtocol.Request.Builder requestBuilder = getRequestBuilder();
-    requestBuilder.setGetRequest(getGetRequestBuilder());
-    messageBuilder.setRequest(requestBuilder);
-    return messageBuilder.build();
-  }
-
-  private static ClientProtocol.Request.Builder getRequestBuilder() {
-    return ClientProtocol.Request.newBuilder();
-  }
-
-  private static RegionAPI.GetRequest.Builder getGetRequestBuilder() {
-    return RegionAPI.GetRequest.newBuilder();
-  }
-
-  private static ClientProtocol.MessageHeader.Builder getMessageHeaderBuilder() {
-    return ClientProtocol.MessageHeader.newBuilder();
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsHandler.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsHandler.java b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsHandler.java
deleted file mode 100644
index 793dace..0000000
--- a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsHandler.java
+++ /dev/null
@@ -1,21 +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.client.protocol;
-
-import org.apache.geode.serialization.registry.SerializationCodecRegistry;
-
-public interface OpsHandler<Req, Resp> {
-  Resp process(SerializationCodecRegistry serializationCodecRegistry, Req request);
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/protocol/IntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/IntegrationJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/IntegrationJUnitTest.java
new file mode 100644
index 0000000..42cc7b3
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/IntegrationJUnitTest.java
@@ -0,0 +1,124 @@
+/*
+ * 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.protocol;
+
+import com.google.protobuf.ByteString;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.Region;
+import org.apache.geode.protocol.protobuf.ProtobufStreamProcessor;
+import org.apache.geode.protocol.protobuf.BasicTypes;
+import org.apache.geode.protocol.protobuf.ClientProtocol;
+import org.apache.geode.protocol.protobuf.RegionAPI;
+import org.apache.geode.serialization.codec.StringCodec;
+import org.apache.geode.protocol.protobuf.EncodingTypeTranslator;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.SerializationCodecRegistry;
+import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+import org.apache.geode.test.dunit.Assert;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+@Category(UnitTest.class)
+public class IntegrationJUnitTest {
+
+  public static final String TEST_KEY = "my key";
+  public static final String TEST_VALUE = "my value";
+  public static final String TEST_REGION = "test region";
+  private StringCodec stringCodec;
+  private Cache cacheStub;
+  private Region regionStub;
+
+  @Before
+  public void setup() throws CodecAlreadyRegisteredForTypeException,
+      UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
+    SerializationCodecRegistry serializationCodecRegistry = new SerializationCodecRegistry();
+    stringCodec = (StringCodec) serializationCodecRegistry.getCodecForType(
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.STRING));
+    regionStub = getRegionStub();
+    cacheStub = getCacheStub(regionStub);
+  }
+
+  @Test
+  public void testGetRequestProcessed() throws Exception {
+    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+
+    ProtobufStreamProcessor streamProcessor = new ProtobufStreamProcessor();
+    streamProcessor.processOneMessage(getInputStream(getRequest(stringCodec)), outputStream,
+        cacheStub);
+
+    RegionAPI.GetResponse getResponse = getGetResponse(outputStream);
+
+    Assert.assertNotNull(getResponse);
+    Assert.assertEquals(BasicTypes.EncodingType.STRING, getResponse.getResult().getEncodingType());
+    String actualValue = stringCodec.decode(getResponse.getResult().getValue().toByteArray());
+    Assert.assertEquals(TEST_VALUE, actualValue);
+    verify(regionStub, times(1)).get(TEST_KEY);
+    verify(regionStub, times(1)).get(anyString());
+  }
+
+  private Region getRegionStub() {
+    regionStub = mock(Region.class);
+    when(regionStub.get(TEST_KEY)).thenReturn(TEST_VALUE);
+    return regionStub;
+  }
+
+  private Cache getCacheStub(Region region) {
+    Cache cacheStub = mock(Cache.class);
+    when(cacheStub.getRegion(TEST_REGION)).thenReturn(region);
+    return cacheStub;
+  }
+
+  private RegionAPI.GetResponse getGetResponse(ByteArrayOutputStream outputStream)
+      throws IOException {
+    ByteArrayInputStream helperInputStream = new ByteArrayInputStream(outputStream.toByteArray());
+    ClientProtocol.Message responseMessage =
+        ClientProtocol.Message.parseDelimitedFrom(helperInputStream);
+    ClientProtocol.Response response = responseMessage.getResponse();
+    return response.getGetResponse();
+  }
+
+  private ByteArrayInputStream getInputStream(ClientProtocol.Message request) throws IOException {
+    ByteArrayOutputStream helperOutputStream = new ByteArrayOutputStream();
+    request.writeDelimitedTo(helperOutputStream);
+    return new ByteArrayInputStream(helperOutputStream.toByteArray());
+  }
+
+  private ClientProtocol.Message getRequest(StringCodec stringCodec) {
+    RegionAPI.GetRequest.Builder getRequestBuilder = RegionAPI.GetRequest.newBuilder();
+    getRequestBuilder.setRegionName(TEST_REGION)
+        .setKey(BasicTypes.EncodedValue.newBuilder().setEncodingType(BasicTypes.EncodingType.STRING)
+            .setValue(ByteString.copyFrom(stringCodec.encode(TEST_KEY))));
+    ClientProtocol.Request request =
+        ClientProtocol.Request.newBuilder().setGetRequest(getRequestBuilder).build();
+    ClientProtocol.Message requestMessage = ClientProtocol.Message.newBuilder()
+        .setMessageHeader(ClientProtocol.MessageHeader.newBuilder()).setRequest(request).build();
+
+    return requestMessage;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/protocol/MessageUtil.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/MessageUtil.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/MessageUtil.java
new file mode 100644
index 0000000..f0b0b41
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/MessageUtil.java
@@ -0,0 +1,41 @@
+/*
+ * 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.protocol;
+
+import org.apache.geode.protocol.protobuf.ClientProtocol;
+import org.apache.geode.protocol.protobuf.RegionAPI;
+
+public class MessageUtil {
+  public static ClientProtocol.Message createGetRequestMessage() {
+    ClientProtocol.Message.Builder messageBuilder = ClientProtocol.Message.newBuilder();
+    messageBuilder.setMessageHeader(getMessageHeaderBuilder());
+    ClientProtocol.Request.Builder requestBuilder = getRequestBuilder();
+    requestBuilder.setGetRequest(getGetRequestBuilder());
+    messageBuilder.setRequest(requestBuilder);
+    return messageBuilder.build();
+  }
+
+  private static ClientProtocol.Request.Builder getRequestBuilder() {
+    return ClientProtocol.Request.newBuilder();
+  }
+
+  private static RegionAPI.GetRequest.Builder getGetRequestBuilder() {
+    return RegionAPI.GetRequest.newBuilder();
+  }
+
+  private static ClientProtocol.MessageHeader.Builder getMessageHeaderBuilder() {
+    return ClientProtocol.MessageHeader.newBuilder();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/protocol/OpsHandler.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/OpsHandler.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/OpsHandler.java
new file mode 100644
index 0000000..2b4aa21
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/OpsHandler.java
@@ -0,0 +1,21 @@
+/*
+ * 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.protocol;
+
+import org.apache.geode.serialization.registry.SerializationCodecRegistry;
+
+public interface OpsHandler<Req, Resp> {
+  Resp process(SerializationCodecRegistry serializationCodecRegistry, Req request);
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandlerTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandlerTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandlerTest.java
deleted file mode 100644
index cb98eb7..0000000
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandlerTest.java
+++ /dev/null
@@ -1,95 +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.protocol.operations.protobuf;
-
-import com.google.protobuf.ByteString;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.Region;
-import org.apache.geode.protocol.protobuf.BasicTypes;
-import org.apache.geode.protocol.protobuf.RegionAPI;
-import org.apache.geode.protocol.protobuf.operations.GetRequestOperationHandler;
-import org.apache.geode.serialization.SerializationService;
-import org.apache.geode.serialization.codec.StringCodec;
-import org.apache.geode.protocol.protobuf.EncodingTypeTranslator;
-import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
-import org.apache.geode.serialization.registry.SerializationCodecRegistry;
-import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
-import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
-import org.apache.geode.test.dunit.Assert;
-import org.apache.geode.test.junit.categories.UnitTest;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.nio.charset.Charset;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@Category(UnitTest.class)
-public class GetRequestOperationHandlerTest {
-  public static final String TEST_KEY = "my key";
-  public static final String TEST_VALUE = "my value";
-  public static final String TEST_REGION = "test region";
-  public Cache cacheStub;
-  public SerializationService serializationServiceStub;
-
-  @Before
-  public void setUp() throws Exception {
-    serializationServiceStub = mock(SerializationService.class);
-    when(serializationServiceStub.decode(BasicTypes.EncodingType.STRING,
-        TEST_KEY.getBytes(Charset.forName("UTF-8")))).thenReturn(TEST_KEY);
-    when(serializationServiceStub.encode(BasicTypes.EncodingType.STRING, TEST_VALUE))
-        .thenReturn(TEST_VALUE.getBytes(Charset.forName("UTF-8")));
-
-    Region regionStub = mock(Region.class);
-    when(regionStub.get(TEST_KEY)).thenReturn(TEST_VALUE);
-
-    cacheStub = mock(Cache.class);
-    when(cacheStub.getRegion(TEST_REGION)).thenReturn(regionStub);
-  }
-
-  @Test
-  public void processReturnsTheEncodedValueFromTheRegion() throws UnsupportedEncodingTypeException,
-      CodecNotRegisteredForTypeException, CodecAlreadyRegisteredForTypeException {
-    GetRequestOperationHandler operationHandler = new GetRequestOperationHandler();
-
-    RegionAPI.GetResponse response =
-        operationHandler.process(serializationServiceStub, makeGetRequest(), cacheStub);
-
-    Assert.assertEquals(BasicTypes.EncodingType.STRING, response.getResult().getEncodingType());
-    String actualValue = getStringCodec().decode(response.getResult().getValue().toByteArray());
-    Assert.assertEquals(TEST_VALUE, actualValue);
-  }
-
-  private RegionAPI.GetRequest makeGetRequest() throws CodecNotRegisteredForTypeException,
-      UnsupportedEncodingTypeException, CodecAlreadyRegisteredForTypeException {
-    StringCodec stringCodec = getStringCodec();
-    RegionAPI.GetRequest.Builder getRequestBuilder = RegionAPI.GetRequest.newBuilder();
-    getRequestBuilder.setRegionName(TEST_REGION)
-        .setKey(BasicTypes.EncodedValue.newBuilder().setEncodingType(BasicTypes.EncodingType.STRING)
-            .setValue(ByteString.copyFrom(stringCodec.encode(TEST_KEY))));
-
-    return getRequestBuilder.build();
-  }
-
-  private StringCodec getStringCodec() throws CodecAlreadyRegisteredForTypeException,
-      CodecNotRegisteredForTypeException, UnsupportedEncodingTypeException {
-    SerializationCodecRegistry serializationCodecRegistry = new SerializationCodecRegistry();
-    return (StringCodec) serializationCodecRegistry.getCodecForType(
-        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.STRING));
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/EncodingTypeToSerializationTypeTranslatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/EncodingTypeToSerializationTypeTranslatorJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/EncodingTypeToSerializationTypeTranslatorJUnitTest.java
new file mode 100644
index 0000000..8e6f66a
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/EncodingTypeToSerializationTypeTranslatorJUnitTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.protocol.protobuf;
+
+import static org.junit.Assert.assertSame;
+
+import org.apache.geode.protocol.protobuf.BasicTypes;
+import org.apache.geode.protocol.protobuf.EncodingTypeTranslator;
+import org.apache.geode.serialization.SerializationType;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(UnitTest.class)
+public class EncodingTypeToSerializationTypeTranslatorJUnitTest {
+
+  @Test
+  public void testTranslateEncodingTypes() throws UnsupportedEncodingTypeException {
+    assertSame(SerializationType.INT,
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.INT));
+    assertSame(SerializationType.LONG,
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.LONG));
+    assertSame(SerializationType.SHORT,
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.SHORT));
+    assertSame(SerializationType.BYTE,
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.BYTE));
+    assertSame(SerializationType.BOOLEAN, EncodingTypeTranslator
+        .getSerializationTypeForEncodingType(BasicTypes.EncodingType.BOOLEAN));
+    assertSame(SerializationType.BINARY,
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.BINARY));
+    assertSame(SerializationType.FLOAT,
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.FLOAT));
+    assertSame(SerializationType.DOUBLE,
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.DOUBLE));
+    assertSame(SerializationType.STRING,
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.STRING));
+    assertSame(SerializationType.JSON,
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.JSON));
+  }
+
+  @Test(expected = UnsupportedEncodingTypeException.class)
+  public void testTranslateInvalidEncoding_throwsException()
+      throws UnsupportedEncodingTypeException {
+    EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.INVALID);
+  }
+
+  @Test
+  public void testAllEncodingTypeTranslations() {
+    for (BasicTypes.EncodingType encodingType : BasicTypes.EncodingType.values()) {
+      if (!(encodingType.equals(BasicTypes.EncodingType.UNRECOGNIZED)
+          || encodingType.equals(BasicTypes.EncodingType.INVALID))) {
+        try {
+          EncodingTypeTranslator.getSerializationTypeForEncodingType(encodingType);
+        } catch (UnsupportedEncodingTypeException e) {
+          e.printStackTrace();
+        }
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorJUnitTest.java
new file mode 100644
index 0000000..fc980ae
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorJUnitTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.protocol.protobuf;
+
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
+import org.apache.geode.protocol.operations.OperationHandler;
+import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry;
+import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException;
+import org.apache.geode.serialization.SerializationService;
+import org.apache.geode.serialization.exception.TypeEncodingException;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(UnitTest.class)
+public class ProtobufOpsProcessorJUnitTest {
+  @Test
+  public void testOpsProcessor() throws TypeEncodingException,
+      OperationHandlerNotRegisteredException, InvalidProtocolMessageException {
+    OperationsHandlerRegistry opsHandlerRegistryStub = mock(OperationsHandlerRegistry.class);
+    OperationHandler operationHandlerStub = mock(OperationHandler.class);
+    SerializationService serializationServiceStub = mock(SerializationService.class);
+    Cache dummyCache = mock(Cache.class);
+    int operationID = ClientProtocol.Request.RequestAPICase.GETREQUEST.getNumber();
+
+    ClientProtocol.Request messageRequest = ClientProtocol.Request.newBuilder()
+        .setGetRequest(RegionAPI.GetRequest.newBuilder()).build();
+
+    RegionAPI.GetResponse expectedResponse = RegionAPI.GetResponse.newBuilder().build();
+
+    when(opsHandlerRegistryStub.getOperationHandlerForOperationId(operationID))
+        .thenReturn(operationHandlerStub);
+    when(operationHandlerStub.process(serializationServiceStub,
+        ProtobufOpsProcessor.getRequestForOperationTypeID(messageRequest), dummyCache))
+            .thenReturn(expectedResponse);
+
+    ProtobufOpsProcessor processor =
+        new ProtobufOpsProcessor(opsHandlerRegistryStub, serializationServiceStub);
+    ClientProtocol.Response response = processor.process(messageRequest, dummyCache);
+    Assert.assertEquals(expectedResponse, response.getGetResponse());
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorTest.java
deleted file mode 100644
index ac3d68f..0000000
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorTest.java
+++ /dev/null
@@ -1,62 +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.protocol.protobuf;
-
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
-import org.apache.geode.protocol.operations.OperationHandler;
-import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry;
-import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException;
-import org.apache.geode.serialization.SerializationService;
-import org.apache.geode.serialization.exception.TypeEncodingException;
-import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
-import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
-import org.apache.geode.test.junit.categories.UnitTest;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-@Category(UnitTest.class)
-public class ProtobufOpsProcessorTest {
-  @Test
-  public void testOpsProcessor() throws TypeEncodingException,
-      OperationHandlerNotRegisteredException, InvalidProtocolMessageException {
-    OperationsHandlerRegistry opsHandlerRegistryStub = mock(OperationsHandlerRegistry.class);
-    OperationHandler operationHandlerStub = mock(OperationHandler.class);
-    SerializationService serializationServiceStub = mock(SerializationService.class);
-    Cache dummyCache = mock(Cache.class);
-    int operationID = ClientProtocol.Request.RequestAPICase.GETREQUEST.getNumber();
-
-    ClientProtocol.Request messageRequest = ClientProtocol.Request.newBuilder()
-        .setGetRequest(RegionAPI.GetRequest.newBuilder()).build();
-
-    RegionAPI.GetResponse expectedResponse = RegionAPI.GetResponse.newBuilder().build();
-
-    when(opsHandlerRegistryStub.getOperationHandlerForOperationId(operationID))
-        .thenReturn(operationHandlerStub);
-    when(operationHandlerStub.process(serializationServiceStub,
-        ProtobufOpsProcessor.getRequestForOperationTypeID(messageRequest), dummyCache))
-            .thenReturn(expectedResponse);
-
-    ProtobufOpsProcessor processor =
-        new ProtobufOpsProcessor(opsHandlerRegistryStub, serializationServiceStub);
-    ClientProtocol.Response response = processor.process(messageRequest, dummyCache);
-    Assert.assertEquals(expectedResponse, response.getGetResponse());
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandlerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandlerJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandlerJUnitTest.java
new file mode 100644
index 0000000..daa5870
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandlerJUnitTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.protocol.protobuf.operations;
+
+import com.google.protobuf.ByteString;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.Region;
+import org.apache.geode.protocol.protobuf.BasicTypes;
+import org.apache.geode.protocol.protobuf.RegionAPI;
+import org.apache.geode.protocol.protobuf.operations.GetRequestOperationHandler;
+import org.apache.geode.serialization.SerializationService;
+import org.apache.geode.serialization.codec.StringCodec;
+import org.apache.geode.protocol.protobuf.EncodingTypeTranslator;
+import org.apache.geode.serialization.exception.TypeEncodingException;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.SerializationCodecRegistry;
+import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+import org.apache.geode.test.dunit.Assert;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.nio.charset.Charset;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@Category(UnitTest.class)
+public class GetRequestOperationHandlerJUnitTest {
+  public static final String TEST_KEY = "my key";
+  public static final String TEST_VALUE = "my value";
+  public static final String TEST_REGION = "test region";
+  public Cache cacheStub;
+  public SerializationService serializationServiceStub;
+
+  @Before
+  public void setUp() throws Exception {
+    serializationServiceStub = mock(SerializationService.class);
+    when(serializationServiceStub.decode(BasicTypes.EncodingType.STRING,
+        TEST_KEY.getBytes(Charset.forName("UTF-8")))).thenReturn(TEST_KEY);
+    when(serializationServiceStub.encode(BasicTypes.EncodingType.STRING, TEST_VALUE))
+        .thenReturn(TEST_VALUE.getBytes(Charset.forName("UTF-8")));
+
+    Region regionStub = mock(Region.class);
+    when(regionStub.get(TEST_KEY)).thenReturn(TEST_VALUE);
+
+    cacheStub = mock(Cache.class);
+    when(cacheStub.getRegion(TEST_REGION)).thenReturn(regionStub);
+  }
+
+  @Test
+  public void processReturnsTheEncodedValueFromTheRegion()
+      throws TypeEncodingException, CodecAlreadyRegisteredForTypeException {
+    GetRequestOperationHandler operationHandler = new GetRequestOperationHandler();
+
+    RegionAPI.GetResponse response =
+        operationHandler.process(serializationServiceStub, makeGetRequest(), cacheStub);
+
+    Assert.assertEquals(BasicTypes.EncodingType.STRING, response.getResult().getEncodingType());
+    String actualValue = getStringCodec().decode(response.getResult().getValue().toByteArray());
+    Assert.assertEquals(TEST_VALUE, actualValue);
+  }
+
+  private RegionAPI.GetRequest makeGetRequest() throws CodecNotRegisteredForTypeException,
+      UnsupportedEncodingTypeException, CodecAlreadyRegisteredForTypeException {
+    StringCodec stringCodec = getStringCodec();
+    RegionAPI.GetRequest.Builder getRequestBuilder = RegionAPI.GetRequest.newBuilder();
+    getRequestBuilder.setRegionName(TEST_REGION)
+        .setKey(BasicTypes.EncodedValue.newBuilder().setEncodingType(BasicTypes.EncodingType.STRING)
+            .setValue(ByteString.copyFrom(stringCodec.encode(TEST_KEY))));
+
+    return getRequestBuilder.build();
+  }
+
+  private StringCodec getStringCodec() throws CodecAlreadyRegisteredForTypeException,
+      CodecNotRegisteredForTypeException, UnsupportedEncodingTypeException {
+    SerializationCodecRegistry serializationCodecRegistry = new SerializationCodecRegistry();
+    return (StringCodec) serializationCodecRegistry.getCodecForType(
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.STRING));
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java
index e1f7b5b..5a94dae 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java
@@ -14,7 +14,7 @@
  */
 package org.apache.geode.protocol.serializer;
 
-import org.apache.geode.client.protocol.MessageUtil;
+import org.apache.geode.protocol.MessageUtil;
 import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
 import org.apache.geode.protocol.protobuf.serializer.ProtobufProtocolSerializer;
 import org.apache.geode.protocol.protobuf.ClientProtocol;

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceImplTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceImplTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceImplTest.java
deleted file mode 100644
index ef841c3..0000000
--- a/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceImplTest.java
+++ /dev/null
@@ -1,58 +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.serialization;
-
-import org.apache.geode.protocol.protobuf.BasicTypes;
-import org.apache.geode.protocol.protobuf.ProtobufSerializationService;
-import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
-import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
-import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
-import org.apache.geode.test.junit.categories.UnitTest;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-@Category(UnitTest.class)
-public class ProtobufSerializationServiceImplTest {
-
-  public static final String PAYLOAD = "my value";
-
-  @Test
-  public void valuesPreservedByEncodingThenDecoding() throws CodecAlreadyRegisteredForTypeException,
-      UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
-    ProtobufSerializationService protobufSerializationService = new ProtobufSerializationService();
-
-    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.STRING, "testString");
-    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.FLOAT, (float) 34.23);
-    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.DOUBLE, 34.23);
-    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.INT, 45);
-    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.SHORT, (short) 45);
-    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BYTE, (byte) 45);
-    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.LONG, (long) 45);
-    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BOOLEAN, false);
-    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BOOLEAN, true);
-    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BINARY,
-        "testString".getBytes());
-    // TODO: Test JSON conversion
-  }
-
-  private void testEncodeDecode(ProtobufSerializationService service,
-      BasicTypes.EncodingType encodingType, Object data)
-      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
-    byte[] encodedValue = service.encode(encodingType, data);
-    Object decodedValue = service.decode(encodingType, encodedValue);
-    Assert.assertEquals(data, decodedValue);
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceJUnitTest.java
new file mode 100644
index 0000000..122c8bc
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceJUnitTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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.serialization;
+
+import org.apache.geode.protocol.protobuf.BasicTypes;
+import org.apache.geode.protocol.protobuf.ProtobufSerializationService;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(UnitTest.class)
+public class ProtobufSerializationServiceJUnitTest {
+
+  public static final String PAYLOAD = "my value";
+  private ProtobufSerializationService protobufSerializationService;
+
+  @Before
+  public void setup() throws CodecAlreadyRegisteredForTypeException {
+    protobufSerializationService = new ProtobufSerializationService();
+  }
+
+  @Test
+  public void stringValuesPreservedByEncodingThenDecoding()
+      throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException,
+      CodecNotRegisteredForTypeException {
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.STRING, "testString");
+  }
+
+  @Test
+  public void floatValuesPreservedByEncodingThenDecoding()
+      throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException,
+      CodecNotRegisteredForTypeException {
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.FLOAT, (float) 34.23);
+  }
+
+  @Test
+  public void doubleValuesPreservedByEncodingThenDecoding()
+      throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException,
+      CodecNotRegisteredForTypeException {
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.DOUBLE, 34.23);
+  }
+
+  @Test
+  public void intValuesPreservedByEncodingThenDecoding()
+      throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException,
+      CodecNotRegisteredForTypeException {
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.INT, 45);
+  }
+
+  @Test
+  public void shortValuesPreservedByEncodingThenDecoding()
+      throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException,
+      CodecNotRegisteredForTypeException {
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.SHORT, (short) 45);
+  }
+
+  @Test
+  public void byteValuesPreservedByEncodingThenDecoding()
+      throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException,
+      CodecNotRegisteredForTypeException {
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BYTE, (byte) 45);
+  }
+
+  @Test
+  public void longValuesPreservedByEncodingThenDecoding()
+      throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException,
+      CodecNotRegisteredForTypeException {
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.LONG, (long) 45);
+  }
+
+  @Test
+  public void booleanValuesPreservedByEncodingThenDecoding()
+      throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException,
+      CodecNotRegisteredForTypeException {
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BOOLEAN, false);
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BOOLEAN, true);
+  }
+
+  @Test
+  public void binaryValuesPreservedByEncodingThenDecoding()
+      throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException,
+      CodecNotRegisteredForTypeException {
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BINARY,
+        "testString".getBytes());
+  }
+
+  private void testEncodeDecode(ProtobufSerializationService service,
+      BasicTypes.EncodingType encodingType, Object data)
+      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
+    byte[] encodedValue = service.encode(encodingType, data);
+    Object decodedValue = service.decode(encodingType, encodedValue);
+    Assert.assertEquals(data, decodedValue);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/BinaryFormatJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/BinaryFormatJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/BinaryFormatJUnitTest.java
new file mode 100644
index 0000000..dd72a19
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/BinaryFormatJUnitTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.serialization.codec;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.nio.charset.Charset;
+
+@Category(UnitTest.class)
+public class BinaryFormatJUnitTest {
+  private static final Charset UTF8 = Charset.forName("UTF-8");
+  private static final Charset UTF16 = Charset.forName("UTF-16");
+  private String testString = "Test String";
+
+  private StringCodec stringCodec;
+
+  @Before
+  public void startup() {
+    stringCodec = new StringCodec();
+  }
+
+  @Test
+  public void testStringsUseUTF8Encoding() {
+    assertArrayEquals(testString.getBytes(UTF8), stringCodec.encode(testString));
+  }
+
+  @Test
+  public void testStringDontUseUTF16Encoding() {
+    byte[] expectedEncodedString = stringCodec.encode(testString);
+    byte[] incorrectEncodedString = testString.getBytes(UTF16);
+    assertNotEquals(expectedEncodedString.length, incorrectEncodedString.length);
+  }
+
+  @Test
+  public void testImproperlyEncodedStringDecodingFails() {
+    byte[] encodedString = testString.getBytes(UTF16);
+    assertNotEquals(testString, stringCodec.decode(encodedString));
+  }
+
+  @Test
+  public void testProperlyEncodedStringDecoding() {
+    byte[] encodedString = testString.getBytes(UTF8);
+    assertEquals(testString, stringCodec.decode(encodedString));
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/StringCodecJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/StringCodecJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/StringCodecJUnitTest.java
deleted file mode 100644
index 8cd6029..0000000
--- a/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/StringCodecJUnitTest.java
+++ /dev/null
@@ -1,64 +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.serialization.codec;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-
-import org.apache.geode.test.junit.categories.UnitTest;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.nio.charset.Charset;
-
-@Category(UnitTest.class)
-public class StringCodecJUnitTest {
-  private static final Charset UTF8 = Charset.forName("UTF-8");
-  private static final Charset UTF16 = Charset.forName("UTF-16");
-  private String testString = "Test String";
-
-  private StringCodec stringCodec;
-
-  @Before
-  public void startup() {
-    stringCodec = new StringCodec();
-  }
-
-  @Test
-  public void testStringEncoding() {
-    assertArrayEquals(testString.getBytes(UTF8), stringCodec.encode(testString));
-  }
-
-  @Test
-  public void testStringIncompatibleEncoding() {
-    byte[] expectedEncodedString = stringCodec.encode(testString);
-    byte[] incorrectEncodedString = testString.getBytes(UTF16);
-    assertNotEquals(expectedEncodedString.length, incorrectEncodedString.length);
-  }
-
-  @Test
-  public void testStringDecodingWithIncorrectEncodedString() {
-    byte[] encodedString = testString.getBytes(UTF16);
-    assertNotEquals(testString, stringCodec.decode(encodedString));
-  }
-
-  @Test
-  public void testStringDecoding() {
-    byte[] encodedString = testString.getBytes(UTF8);
-    assertEquals(testString, stringCodec.decode(encodedString));
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslatorJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslatorJUnitTest.java
deleted file mode 100644
index 963cb85..0000000
--- a/geode-protobuf/src/test/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslatorJUnitTest.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.serialization.protobuf.translation;
-
-import static org.junit.Assert.assertSame;
-
-import org.apache.geode.protocol.protobuf.BasicTypes;
-import org.apache.geode.protocol.protobuf.EncodingTypeTranslator;
-import org.apache.geode.serialization.SerializationType;
-import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
-import org.apache.geode.test.junit.categories.UnitTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-@Category(UnitTest.class)
-public class EncodingTypeToSerializationTypeTranslatorJUnitTest {
-
-  @Test
-  public void testTranslateEncodingTypes() throws UnsupportedEncodingTypeException {
-    assertSame(SerializationType.INT,
-        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.INT));
-    assertSame(SerializationType.LONG,
-        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.LONG));
-    assertSame(SerializationType.SHORT,
-        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.SHORT));
-    assertSame(SerializationType.BYTE,
-        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.BYTE));
-    assertSame(SerializationType.BOOLEAN, EncodingTypeTranslator
-        .getSerializationTypeForEncodingType(BasicTypes.EncodingType.BOOLEAN));
-    assertSame(SerializationType.BINARY,
-        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.BINARY));
-    assertSame(SerializationType.FLOAT,
-        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.FLOAT));
-    assertSame(SerializationType.DOUBLE,
-        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.DOUBLE));
-    assertSame(SerializationType.STRING,
-        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.STRING));
-    assertSame(SerializationType.JSON,
-        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.JSON));
-  }
-
-  @Test(expected = UnsupportedEncodingTypeException.class)
-  public void testTranslateInvalidEncoding_throwsException()
-      throws UnsupportedEncodingTypeException {
-    EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.INVALID);
-  }
-
-  @Test
-  public void testAllEncodingTypeTranslations() {
-    for (BasicTypes.EncodingType encodingType : BasicTypes.EncodingType.values()) {
-      if (!(encodingType.equals(BasicTypes.EncodingType.UNRECOGNIZED)
-          || encodingType.equals(BasicTypes.EncodingType.INVALID))) {
-        try {
-          EncodingTypeTranslator.getSerializationTypeForEncodingType(encodingType);
-        } catch (UnsupportedEncodingTypeException e) {
-          e.printStackTrace();
-        }
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/gradle/dependency-versions.properties
----------------------------------------------------------------------
diff --git a/gradle/dependency-versions.properties b/gradle/dependency-versions.properties
index 183dafc..6a730a4 100644
--- a/gradle/dependency-versions.properties
+++ b/gradle/dependency-versions.properties
@@ -77,6 +77,9 @@ netty-all.version = 4.1.8.Final
 open-json.version = 1.8
 phantomjsdriver.version=1.3.0
 powermock.version = 1.7.0RC4
+protobuf-gradle-plugin.version = 0.8.1
+protobuf-java.version = 3.3.1
+protoc.version = 3.0.0
 selenium.version=3.0.1
 shiro.version=1.3.2
 slf4j-api.version = 1.7.23


[34/46] geode git commit: GEODE-3075: Initial refactor adding NewProtocolServerConnection

Posted by zh...@apache.org.
GEODE-3075: Initial refactor adding NewProtocolServerConnection

subclassing `ServerConnection`.

The new code is broken but it won't be called under normal operation,
since it's gated on a system property, "geode.feature-protobuf-protocol"

Further refactoring and feature work to come.


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

Branch: refs/heads/feature/GEM-1483
Commit: dfdde4af352566d60f18b0db156fc5b7f48ebd8b
Parents: 49123c4
Author: Galen OSullivan <go...@pivotal.io>
Authored: Mon Jun 12 09:33:35 2017 -0700
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Mon Jun 26 09:26:22 2017 -0700

----------------------------------------------------------------------
 .../geode/internal/cache/tier/Acceptor.java     |  4 +
 .../cache/tier/sockets/AcceptorImpl.java        | 10 +--
 .../cache/tier/sockets/ClientHealthMonitor.java |  7 +-
 .../sockets/ClientProtocolMessageHandler.java   | 29 +++++++
 .../tier/sockets/LegacyServerConnection.java    | 88 ++++++++++++++++++++
 .../sockets/NewProtocolServerConnection.java    | 86 +++++++++++++++++++
 .../cache/tier/sockets/ServerConnection.java    | 75 +++++++----------
 .../tier/sockets/ServerConnectionFactory.java   | 50 +++++++++++
 .../sockets/ServerConnectionFactoryTest.java    | 77 +++++++++++++++++
 .../tier/sockets/ServerConnectionTest.java      |  7 +-
 10 files changed, 375 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/dfdde4af/geode-core/src/main/java/org/apache/geode/internal/cache/tier/Acceptor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/Acceptor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/Acceptor.java
index 9a3241b..a95195a 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/Acceptor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/Acceptor.java
@@ -71,6 +71,10 @@ public abstract class Acceptor {
    */
   public static final byte CLIENT_TO_SERVER_FOR_QUEUE = (byte) 107;
 
+  /**
+   * For the new client-server protocol, which ignores the usual handshake mechanism.
+   */
+  public static final byte CLIENT_TO_SERVER_NEW_PROTOCOL = (byte) 110;
 
   /**
    * The GFE version of the server.

http://git-wip-us.apache.org/repos/asf/geode/blob/dfdde4af/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/AcceptorImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/AcceptorImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/AcceptorImpl.java
index 2a8818c..24efc93 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/AcceptorImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/AcceptorImpl.java
@@ -1422,8 +1422,8 @@ public class AcceptorImpl extends Acceptor implements Runnable {
     s.setTcpNoDelay(this.tcpNoDelay);
 
     if (communicationMode == CLIENT_TO_SERVER || communicationMode == GATEWAY_TO_GATEWAY
-        || communicationMode == MONITOR_TO_SERVER
-        || communicationMode == CLIENT_TO_SERVER_FOR_QUEUE) {
+        || communicationMode == MONITOR_TO_SERVER || communicationMode == CLIENT_TO_SERVER_FOR_QUEUE
+        || communicationMode == CLIENT_TO_SERVER_NEW_PROTOCOL) {
       String communicationModeStr = "";
       switch (communicationMode) {
         case CLIENT_TO_SERVER:
@@ -1466,9 +1466,9 @@ public class AcceptorImpl extends Acceptor implements Runnable {
           return;
         }
       }
-      ServerConnection serverConn = new ServerConnection(s, this.cache, this.crHelper, this.stats,
-          AcceptorImpl.handShakeTimeout, this.socketBufferSize, communicationModeStr,
-          communicationMode, this, this.securityService);
+      ServerConnection serverConn = ServerConnectionFactory.makeServerConnection(s, this.cache,
+          this.crHelper, this.stats, AcceptorImpl.handShakeTimeout, this.socketBufferSize,
+          communicationModeStr, communicationMode, this, this.securityService);
       synchronized (this.allSCsLock) {
         this.allSCs.add(serverConn);
         ServerConnection snap[] = this.allSCList; // avoid volatile read

http://git-wip-us.apache.org/repos/asf/geode/blob/dfdde4af/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientHealthMonitor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientHealthMonitor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientHealthMonitor.java
index e0b5ab8..35cc33f 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientHealthMonitor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientHealthMonitor.java
@@ -478,12 +478,7 @@ public class ClientHealthMonitor {
           Iterator connectionsIterator = connections.iterator();
           while (connectionsIterator.hasNext()) {
             ServerConnection sc = (ServerConnection) connectionsIterator.next();
-            byte communicationMode = sc.getCommunicationMode();
-            /* Check for all modes that could be used for Client-Server communication */
-            if (communicationMode == Acceptor.CLIENT_TO_SERVER
-                || communicationMode == Acceptor.PRIMARY_SERVER_TO_CLIENT
-                || communicationMode == Acceptor.SECONDARY_SERVER_TO_CLIENT
-                || communicationMode == Acceptor.CLIENT_TO_SERVER_FOR_QUEUE) {
+            if (sc.isClientServerConnection()) {
               memberId = sc.getMembershipID(); // each ServerConnection has the same member id
               cci.setMemberId(memberId);
               cci.setNumberOfConnections(connections.size());

http://git-wip-us.apache.org/repos/asf/geode/blob/dfdde4af/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java
new file mode 100644
index 0000000..db42330
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java
@@ -0,0 +1,29 @@
+/*
+ * 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.internal.cache.tier.sockets;
+
+import org.apache.geode.internal.cache.InternalCache;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * Stub, this will be hooked up to the new client protocol when it's implemented.
+ */
+public class ClientProtocolMessageHandler {
+  public void receiveMessage(InputStream inputStream, OutputStream outputStream,
+      InternalCache cache) {}
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/dfdde4af/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/LegacyServerConnection.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/LegacyServerConnection.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/LegacyServerConnection.java
new file mode 100644
index 0000000..2b46eb3
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/LegacyServerConnection.java
@@ -0,0 +1,88 @@
+/*
+ * 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.internal.cache.tier.sockets;
+
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.cache.tier.Acceptor;
+import org.apache.geode.internal.cache.tier.CachedRegionHelper;
+import org.apache.geode.internal.i18n.LocalizedStrings;
+import org.apache.geode.internal.logging.log4j.LocalizedMessage;
+import org.apache.geode.internal.security.SecurityService;
+
+import java.io.IOException;
+import java.net.Socket;
+
+/**
+ * Handles everything but the new client protocol.
+ *
+ * Legacy is therefore a bit of a misnomer; do you have a better name?
+ */
+public class LegacyServerConnection extends ServerConnection {
+  /**
+   * Set to false once handshake has been done
+   */
+  private boolean doHandshake = true;
+
+  /**
+   * Creates a new <code>ServerConnection</code> that processes messages received from an edge
+   * client over a given <code>Socket</code>.
+   *
+   * @param socket
+   * @param internalCache
+   * @param helper
+   * @param stats
+   * @param hsTimeout
+   * @param socketBufferSize
+   * @param communicationModeStr
+   * @param communicationMode
+   * @param acceptor
+   * @param securityService
+   */
+  public LegacyServerConnection(Socket socket, InternalCache internalCache,
+      CachedRegionHelper helper, CacheServerStats stats, int hsTimeout, int socketBufferSize,
+      String communicationModeStr, byte communicationMode, Acceptor acceptor,
+      SecurityService securityService) {
+    super(socket, internalCache, helper, stats, hsTimeout, socketBufferSize, communicationModeStr,
+        communicationMode, acceptor, securityService);
+  }
+
+  @Override
+  protected boolean doHandShake(byte epType, int qSize) {
+    try {
+      this.handshake.accept(theSocket.getOutputStream(), theSocket.getInputStream(), epType, qSize,
+          this.communicationMode, this.principal);
+    } catch (IOException ioe) {
+      if (!crHelper.isShutdown() && !isTerminated()) {
+        logger.warn(LocalizedMessage.create(
+            LocalizedStrings.ServerConnection_0_HANDSHAKE_ACCEPT_FAILED_ON_SOCKET_1_2,
+            new Object[] {this.name, this.theSocket, ioe}));
+      }
+      cleanup();
+      return false;
+    }
+    return true;
+  }
+
+  protected void doOneMessage() {
+    if (this.doHandshake) {
+      doHandshake();
+      this.doHandshake = false;
+    } else {
+      this.resetTransientData();
+      doNormalMsg();
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/dfdde4af/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/NewProtocolServerConnection.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/NewProtocolServerConnection.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/NewProtocolServerConnection.java
new file mode 100644
index 0000000..a78cd1c
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/NewProtocolServerConnection.java
@@ -0,0 +1,86 @@
+/*
+ * 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.internal.cache.tier.sockets;
+
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.cache.tier.Acceptor;
+import org.apache.geode.internal.cache.tier.CachedRegionHelper;
+import org.apache.geode.internal.security.SecurityService;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+
+/**
+ * Holds the socket and protocol handler for the new client protocol. TODO: Currently unimplemented
+ * due the the protocol not being there.
+ */
+public class NewProtocolServerConnection extends ServerConnection {
+  // The new protocol lives in a separate module and gets loaded when this class is instantiated.
+  // TODO implement this.
+  private final ClientProtocolMessageHandler newClientProtocol;
+
+
+  /**
+   * Creates a new <code>NewProtocolServerConnection</code> that processes messages received from an
+   * edge client over a given <code>Socket</code>.
+   *
+   * @param s
+   * @param c
+   * @param helper
+   * @param stats
+   * @param hsTimeout
+   * @param socketBufferSize
+   * @param communicationModeStr
+   * @param communicationMode
+   * @param acceptor
+   */
+  public NewProtocolServerConnection(Socket s, InternalCache c, CachedRegionHelper helper,
+                                     CacheServerStats stats, int hsTimeout, int socketBufferSize, String communicationModeStr,
+                                     byte communicationMode, Acceptor acceptor, ClientProtocolMessageHandler newClientProtocol,
+                                     SecurityService securityService) {
+    super(s, c, helper, stats, hsTimeout, socketBufferSize, communicationModeStr, communicationMode,
+        acceptor, securityService);
+    assert (communicationMode == AcceptorImpl.CLIENT_TO_SERVER_NEW_PROTOCOL);
+    this.newClientProtocol = newClientProtocol;
+  }
+
+  @Override
+  protected void doOneMessage() {
+    try {
+      Socket socket = this.getSocket();
+      InputStream inputStream = socket.getInputStream();
+      OutputStream outputStream = socket.getOutputStream();
+      // TODO serialization types?
+      newClientProtocol.receiveMessage(inputStream, outputStream, this.getCache());
+    } catch (IOException e) {
+      // TODO?
+    }
+    return;
+  }
+
+  @Override
+  protected boolean doHandShake(byte epType, int qSize) {
+    // no handshake for new client protocol.
+    return true;
+  }
+
+  @Override
+  public boolean isClientServerConnection() {
+    return true;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/dfdde4af/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnection.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnection.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnection.java
index 947b836..ebc9dab 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnection.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnection.java
@@ -74,9 +74,9 @@ import org.apache.geode.security.GemFireSecurityException;
  *
  * @since GemFire 2.0.2
  */
-public class ServerConnection implements Runnable {
+public abstract class ServerConnection implements Runnable {
 
-  private static final Logger logger = LogService.getLogger();
+  protected static final Logger logger = LogService.getLogger();
 
   /**
    * This is a buffer that we add to client readTimeout value before we cleanup the connection. This
@@ -138,12 +138,12 @@ public class ServerConnection implements Runnable {
     }
   }
 
-  private Socket theSocket;
+  protected Socket theSocket;
   // private InputStream in = null;
   // private OutputStream out = null;
   private ByteBuffer commBuffer;
-  private final CachedRegionHelper crHelper;
-  private String name = null;
+  protected final CachedRegionHelper crHelper;
+  protected String name = null;
 
   // IMPORTANT: if new messages are added change setHandshake to initialize them
   // to the correct Version for serializing to the client
@@ -168,7 +168,7 @@ public class ServerConnection implements Runnable {
   /**
    * Handshake reference uniquely identifying a client
    */
-  private ClientHandShake handshake;
+  protected ClientHandShake handshake;
   private int handShakeTimeout;
   private final Object handShakeMonitor = new Object();
 
@@ -213,7 +213,7 @@ public class ServerConnection implements Runnable {
    * The communication mode for this <code>ServerConnection</code>. Valid types include
    * 'client-server', 'gateway-gateway' and 'monitor-server'.
    */
-  private final byte communicationMode;
+  protected final byte communicationMode;
   private final String communicationModeStr;
 
   private long processingMessageStartTime = -1;
@@ -233,7 +233,7 @@ public class ServerConnection implements Runnable {
 
   private Part securePart = null;
 
-  private Principal principal;
+  protected Principal principal;
 
   private MessageIdExtractor messageIdExtractor = new MessageIdExtractor();
 
@@ -592,19 +592,14 @@ public class ServerConnection implements Runnable {
     }
   }
 
-  private boolean acceptHandShake(byte epType, int qSize) {
-    try {
-      this.handshake.accept(theSocket.getOutputStream(), theSocket.getInputStream(), epType, qSize,
-          this.communicationMode, this.principal);
-    } catch (IOException ioe) {
-      if (!crHelper.isShutdown() && !isTerminated()) {
-        logger.warn(LocalizedMessage.create(
-            LocalizedStrings.ServerConnection_0_HANDSHAKE_ACCEPT_FAILED_ON_SOCKET_1_2,
-            new Object[] {this.name, this.theSocket, ioe}));
-      }
-      cleanup();
-      return false;
-    }
+  protected boolean acceptHandShake(byte epType, int qSize) {
+    return doHandShake(epType, qSize) && handshakeAccepted();
+  }
+
+  protected abstract boolean doHandShake(byte epType, int qSize);
+
+
+  protected boolean handshakeAccepted() {
     if (logger.isDebugEnabled()) {
       logger.debug("{}: Accepted handshake", this.name);
     }
@@ -670,6 +665,16 @@ public class ServerConnection implements Runnable {
     }
   }
 
+  /**
+   * @return whether this is a connection to a client, regardless of protocol.
+   */
+  public boolean isClientServerConnection() {
+    return communicationMode == Acceptor.CLIENT_TO_SERVER
+        || communicationMode == Acceptor.PRIMARY_SERVER_TO_CLIENT
+        || communicationMode == Acceptor.SECONDARY_SERVER_TO_CLIENT
+        || communicationMode == Acceptor.CLIENT_TO_SERVER_FOR_QUEUE;
+  }
+
   static class Counter {
     int cnt;
 
@@ -686,22 +691,12 @@ public class ServerConnection implements Runnable {
     }
   }
 
-  // public void setUserAuthAttributes(ClientProxyMembershipID proxyId, AuthorizeRequest
-  // authzRequest, AuthorizeRequestPP postAuthzRequest) {
-  // UserAuthAttributes uaa = new UserAuthAttributes(authzRequest, postAuthzRequest);
-  // }
-
-  /**
-   * Set to false once handshake has been done
-   */
-  private boolean doHandshake = true;
-
   private boolean clientDisconnectedCleanly = false;
   private Throwable clientDisconnectedException;
   private int failureCount = 0;
   private boolean processMessages = true;
 
-  private void doHandshake() {
+  protected void doHandshake() {
     // hitesh:to create new connection handshake
     if (verifyClientConnection()) {
       // Initialize the commands after the handshake so that the version
@@ -718,7 +713,7 @@ public class ServerConnection implements Runnable {
     }
   }
 
-  private void doNormalMsg() {
+  protected void doNormalMsg() {
     Message msg = null;
     msg = BaseCommand.readRequest(this);
     ThreadState threadState = null;
@@ -903,15 +898,7 @@ public class ServerConnection implements Runnable {
     }
   }
 
-  private void doOneMessage() {
-    if (this.doHandshake) {
-      doHandshake();
-      this.doHandshake = false;
-    } else {
-      this.resetTransientData();
-      doNormalMsg();
-    }
-  }
+  protected abstract void doOneMessage();
 
   private void initializeClientUserAuths() {
     this.clientUserAuths = getClientUserAuths(this.proxyId);
@@ -1070,7 +1057,7 @@ public class ServerConnection implements Runnable {
   /**
    * MessageType of the messages (typically internal commands) which do not need to participate in
    * security should be added in the following if block.
-   * 
+   *
    * @return Part
    * @see AbstractOp#processSecureBytes(Connection, Message)
    * @see AbstractOp#needsUserId()
@@ -1495,7 +1482,7 @@ public class ServerConnection implements Runnable {
 
   /**
    * Just ensure that this class gets loaded.
-   * 
+   *
    * @see SystemFailure#loadEmergencyClasses()
    */
   public static void loadEmergencyClasses() {

http://git-wip-us.apache.org/repos/asf/geode/blob/dfdde4af/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactory.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactory.java
new file mode 100644
index 0000000..4f2e304
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactory.java
@@ -0,0 +1,50 @@
+/*
+ * 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.internal.cache.tier.sockets;
+
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.cache.tier.Acceptor;
+import org.apache.geode.internal.cache.tier.CachedRegionHelper;
+import org.apache.geode.internal.security.SecurityService;
+
+import java.io.IOException;
+import java.net.Socket;
+
+/**
+ * Creates instances of ServerConnection based on the connection mode provided.
+ */
+public class ServerConnectionFactory {
+  // TODO: implement ClientProtocolMessageHandler.
+  private static final ClientProtocolMessageHandler newClientProtocol =
+      new ClientProtocolMessageHandler();
+
+  public static ServerConnection makeServerConnection(Socket s, InternalCache c,
+      CachedRegionHelper helper, CacheServerStats stats, int hsTimeout, int socketBufferSize,
+      String communicationModeStr, byte communicationMode, Acceptor acceptor,
+      SecurityService securityService) throws IOException {
+    if (communicationMode == Acceptor.CLIENT_TO_SERVER_NEW_PROTOCOL) {
+      if (!Boolean.getBoolean("geode.feature-protobuf-protocol")) {
+        throw new IOException("Acceptor received unknown communication mode: " + communicationMode);
+      } else {
+        return new NewProtocolServerConnection(s, c, helper, stats, hsTimeout, socketBufferSize,
+            communicationModeStr, communicationMode, acceptor, newClientProtocol, securityService);
+      }
+    } else {
+      return new LegacyServerConnection(s, c, helper, stats, hsTimeout, socketBufferSize,
+          communicationModeStr, communicationMode, acceptor, securityService);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/dfdde4af/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java
new file mode 100644
index 0000000..c314944
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.internal.cache.tier.sockets;
+
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.cache.tier.Acceptor;
+import org.apache.geode.internal.cache.tier.CachedRegionHelper;
+import org.apache.geode.internal.security.SecurityService;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+public class ServerConnectionFactoryTest {
+  /**
+   * Safeguard that we won't create the new client protocol object unless the feature flag is enabled.
+   */
+  @Test(expected = IOException.class)
+  public void newClientProtocolThrows() throws Exception {
+    serverConnectionMockedExceptForCommunicationMode(Acceptor.CLIENT_TO_SERVER_NEW_PROTOCOL);
+  }
+
+  @Test
+  public void newClientProtocolSucceedsWithSystemPropertySet() throws Exception {
+    System.setProperty("geode.feature-protobuf-protocol", "true");
+    ServerConnection serverConnection = serverConnectionMockedExceptForCommunicationMode(Acceptor.CLIENT_TO_SERVER_NEW_PROTOCOL);
+    assertTrue(serverConnection instanceof NewProtocolServerConnection);
+    System.clearProperty("geode.feature-protobuf-protocol");
+  }
+
+  @Test
+  public void makeServerConnection() throws Exception {
+    byte[] communicationModes = new byte[]{
+      Acceptor.CLIENT_TO_SERVER,
+      Acceptor.PRIMARY_SERVER_TO_CLIENT,
+      Acceptor.SECONDARY_SERVER_TO_CLIENT,
+      Acceptor.GATEWAY_TO_GATEWAY,
+      Acceptor.MONITOR_TO_SERVER,
+      Acceptor.SUCCESSFUL_SERVER_TO_CLIENT,
+      Acceptor.UNSUCCESSFUL_SERVER_TO_CLIENT,
+      Acceptor.CLIENT_TO_SERVER_FOR_QUEUE,
+    };
+
+    for (byte communicationMode : communicationModes) {
+      ServerConnection serverConnection = serverConnectionMockedExceptForCommunicationMode(communicationMode);
+      assertTrue(serverConnection instanceof LegacyServerConnection);
+    }
+  }
+
+  private static ServerConnection serverConnectionMockedExceptForCommunicationMode(byte communicationMode) throws IOException {
+    Socket socketMock = mock(Socket.class);
+    when(socketMock.getInetAddress()).thenReturn(InetAddress.getByName("localhost"));
+
+    return ServerConnectionFactory.makeServerConnection(
+      socketMock, mock(InternalCache.class), mock(CachedRegionHelper.class),
+      mock(CacheServerStats.class), 0, 0, "",
+      communicationMode, mock(AcceptorImpl.class), mock(SecurityService.class));
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/dfdde4af/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionTest.java
index 794c610..d3ef21f 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionTest.java
@@ -39,6 +39,7 @@ import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 
+import java.io.IOException;
 import java.net.InetAddress;
 import java.net.Socket;
 
@@ -57,7 +58,7 @@ public class ServerConnectionTest {
   private ServerConnection serverConnection;
 
   @Before
-  public void setUp() {
+  public void setUp() throws IOException {
     AcceptorImpl acceptor = mock(AcceptorImpl.class);
 
     InetAddress inetAddress = mock(InetAddress.class);
@@ -69,8 +70,8 @@ public class ServerConnectionTest {
     InternalCache cache = mock(InternalCache.class);
     SecurityService securityService = mock(SecurityService.class);
 
-    serverConnection = new ServerConnection(socket, cache, null, null, 0, 0, null,
-        Acceptor.PRIMARY_SERVER_TO_CLIENT, acceptor, securityService);
+    serverConnection = ServerConnectionFactory.makeServerConnection(socket, cache, null, null, 0, 0,
+        null, Acceptor.PRIMARY_SERVER_TO_CLIENT, acceptor, securityService);
     MockitoAnnotations.initMocks(this);
   }
 


[14/46] geode git commit: GEODE-3095: fix parameter type mismatch between the diskstore command and controller

Posted by zh...@apache.org.
GEODE-3095: fix parameter type mismatch between the diskstore command and controller


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

Branch: refs/heads/feature/GEM-1483
Commit: ee5f60c7fdac7227983a7e3bfac7094593e15ed0
Parents: d8a11d1
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Mon Jun 19 11:02:20 2017 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Mon Jun 19 21:18:59 2017 -0700

----------------------------------------------------------------------
 .../web/controllers/DiskStoreCommandsController.java | 11 ++++++-----
 .../management/internal/security/TestCommand.java    | 15 +++++++++------
 2 files changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/ee5f60c7/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DiskStoreCommandsController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DiskStoreCommandsController.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DiskStoreCommandsController.java
index c613a8a..2e06811 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DiskStoreCommandsController.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/DiskStoreCommandsController.java
@@ -14,9 +14,8 @@
  */
 package org.apache.geode.management.internal.web.controllers;
 
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
+import java.util.concurrent.Callable;
+
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -25,7 +24,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
-import java.util.concurrent.Callable;
+import org.apache.geode.internal.lang.StringUtils;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 
 /**
  * The DiskStoreCommandsController class implements GemFire Management REST API web service
@@ -107,7 +108,7 @@ public class DiskStoreCommandsController extends AbstractCommandsController {
       @RequestParam(value = CliStrings.CREATE_DISK_STORE__DISK_USAGE_WARNING_PCT,
           defaultValue = "90") final Float diskUsageWarningPercentage,
       @RequestParam(value = CliStrings.CREATE_DISK_STORE__DISK_USAGE_CRITICAL_PCT,
-          defaultValue = "99") final Integer diskUsageCriticalPercentage,
+          defaultValue = "99") final Float diskUsageCriticalPercentage,
       @RequestParam(value = CliStrings.GROUP, required = false) final String[] groups) {
     CommandStringBuilder command = new CommandStringBuilder(CliStrings.CREATE_DISK_STORE);
 

http://git-wip-us.apache.org/repos/asf/geode/blob/ee5f60c7/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java
index ea4b60d..800d0da 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java
@@ -14,14 +14,16 @@
  */
 package org.apache.geode.management.internal.security;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.apache.shiro.authz.Permission;
+
 import org.apache.geode.security.ResourcePermission;
-import org.apache.geode.security.ResourcePermission.Target;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.apache.shiro.authz.Permission;
-
-import java.util.ArrayList;
-import java.util.List;
+import org.apache.geode.security.ResourcePermission.Target;
 
 public class TestCommand {
 
@@ -77,7 +79,8 @@ public class TestCommand {
   }
 
   public static List<TestCommand> getCommands() {
-    return testCommands;
+    // returns a copy of the list every time
+    return testCommands.stream().collect(Collectors.toList());
   }
 
   public static List<TestCommand> getPermittedCommands(Permission permission) {


[23/46] geode git commit: GEODE-2919: Provide finer grained security

Posted by zh...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java
index 7ce0438..abe5d21 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java
@@ -15,9 +15,11 @@
 package org.apache.geode.management.internal.security;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Collectors;
 
+import org.apache.commons.lang.ArrayUtils;
 import org.apache.shiro.authz.Permission;
 
 import org.apache.geode.security.ResourcePermission;
@@ -46,10 +48,22 @@ public class TestCommand {
 
   public static ResourcePermission clusterRead =
       new ResourcePermission(Resource.CLUSTER, Operation.READ);
+  public static ResourcePermission clusterReadQuery =
+      new ResourcePermission(Resource.CLUSTER, Operation.READ, Target.QUERY);
   public static ResourcePermission clusterWrite =
       new ResourcePermission(Resource.CLUSTER, Operation.WRITE);
+  public static ResourcePermission clusterWriteDisk =
+      new ResourcePermission(Resource.CLUSTER, Operation.WRITE, Target.DISK);
   public static ResourcePermission clusterManage =
       new ResourcePermission(Resource.CLUSTER, Operation.MANAGE);
+  public static ResourcePermission clusterManageDisk =
+      new ResourcePermission(Resource.CLUSTER, Operation.MANAGE, Target.DISK);
+  public static ResourcePermission clusterManageGateway =
+      new ResourcePermission(Resource.CLUSTER, Operation.MANAGE, Target.GATEWAY);
+  public static ResourcePermission clusterManageJar =
+      new ResourcePermission(Resource.CLUSTER, Operation.MANAGE, Target.JAR);
+  public static ResourcePermission clusterManageQuery =
+      new ResourcePermission(Resource.CLUSTER, Operation.MANAGE, Target.QUERY);
 
   private static List<TestCommand> testCommands = new ArrayList<>();
 
@@ -58,15 +72,15 @@ public class TestCommand {
   }
 
   private final String command;
-  private final ResourcePermission permission;
+  private final ResourcePermission[] permissions;
 
-  public TestCommand(String command, ResourcePermission permission) {
+  public TestCommand(String command, ResourcePermission... permissions) {
     this.command = command;
-    this.permission = permission;
+    this.permissions = permissions;
   }
 
-  private static void createTestCommand(String command, ResourcePermission permission) {
-    TestCommand instance = new TestCommand(command, permission);
+  private static void createTestCommand(String command, ResourcePermission... permissions) {
+    TestCommand instance = new TestCommand(command, permissions);
     testCommands.add(instance);
   }
 
@@ -74,8 +88,8 @@ public class TestCommand {
     return this.command;
   }
 
-  public ResourcePermission getPermission() {
-    return this.permission;
+  public ResourcePermission[] getPermissions() {
+    return this.permissions;
   }
 
   public static List<TestCommand> getCommands() {
@@ -83,11 +97,21 @@ public class TestCommand {
     return testCommands.stream().collect(Collectors.toList());
   }
 
+  public static List<TestCommand> getOnlineCommands() {
+    return testCommands.stream().filter((x) -> ArrayUtils.isNotEmpty(x.getPermissions()))
+        .collect(Collectors.toList());
+  }
+
   public static List<TestCommand> getPermittedCommands(Permission permission) {
     List<TestCommand> result = new ArrayList<>();
     for (TestCommand testCommand : testCommands) {
-      ResourcePermission cPerm = testCommand.getPermission();
-      if (cPerm != null && permission.implies(cPerm)) {
+      ResourcePermission[] cPerms = testCommand.getPermissions();
+      if (cPerms == null || cPerms.length == 0) {
+        // Skip offline commands.
+        continue;
+      }
+      boolean allPermissionsAreImplied = Arrays.stream(cPerms).allMatch(permission::implies);
+      if (allPermissionsAreImplied) {
         result.add(testCommand);
       }
     }
@@ -107,6 +131,11 @@ public class TestCommand {
     // CreateAlterDestroyRegionCommands
     createTestCommand("alter region --name=RegionA --eviction-max=5000", regionAManage);
     createTestCommand("create region --name=region12 --type=REPLICATE", dataManage);
+    createTestCommand("create region --name=region123 --type=PARTITION_PERSISTENT", dataManage,
+        clusterWriteDisk);
+    // This command requires an existing persistent region named "persistentRegion"
+    createTestCommand("create region --name=region1234 --template-region=/persistentRegion",
+        dataManage, clusterWriteDisk);
     createTestCommand("destroy region --name=value", dataManage);
 
     // Data Commands
@@ -124,28 +153,28 @@ public class TestCommand {
     // Deploy commands
     // createTestCommand("deploy --jar=group1_functions.jar --group=Group1", dataManage); // TODO:
     // this command will fail in GfshCommandsSecurityTest at interceptor for jar file checking
-    createTestCommand("undeploy --group=Group1", dataManage);
+    createTestCommand("undeploy --group=Group1", clusterManageJar);
 
     // Diskstore Commands
-    createTestCommand("backup disk-store --dir=foo", dataRead);
+    createTestCommand("backup disk-store --dir=foo", dataRead, clusterWriteDisk);
     createTestCommand("list disk-stores", clusterRead);
-    createTestCommand("create disk-store --name=foo --dir=bar", dataManage);
-    createTestCommand("compact disk-store --name=foo", diskManage);
-    createTestCommand("compact offline-disk-store --name=foo --disk-dirs=bar", null);
-    createTestCommand("upgrade offline-disk-store --name=foo --disk-dirs=bar", null);
+    createTestCommand("create disk-store --name=foo --dir=bar", clusterManageDisk);
+    createTestCommand("compact disk-store --name=foo", clusterManageDisk);
+    createTestCommand("compact offline-disk-store --name=foo --disk-dirs=bar");
+    createTestCommand("upgrade offline-disk-store --name=foo --disk-dirs=bar");
     createTestCommand("describe disk-store --name=foo --member=baz", clusterRead);
-    createTestCommand("revoke missing-disk-store --id=foo", dataManage);
+    createTestCommand("revoke missing-disk-store --id=foo", clusterManageDisk);
     createTestCommand("show missing-disk-stores", clusterRead);
-    createTestCommand("describe offline-disk-store --name=foo --disk-dirs=bar", null);
-    createTestCommand("export offline-disk-store --name=foo --disk-dirs=bar --dir=baz", null);
-    createTestCommand("validate offline-disk-store --name=foo --disk-dirs=bar", null);
-    createTestCommand("alter disk-store --name=foo --region=xyz --disk-dirs=bar", null);
-    createTestCommand("destroy disk-store --name=foo", dataManage);
+    createTestCommand("describe offline-disk-store --name=foo --disk-dirs=bar");
+    createTestCommand("export offline-disk-store --name=foo --disk-dirs=bar --dir=baz");
+    createTestCommand("validate offline-disk-store --name=foo --disk-dirs=bar");
+    createTestCommand("alter disk-store --name=foo --region=xyz --disk-dirs=bar");
+    createTestCommand("destroy disk-store --name=foo", clusterManageDisk);
 
     // DurableClientCommands
-    createTestCommand("close durable-client --durable-client-id=client1", dataManage);
+    createTestCommand("close durable-client --durable-client-id=client1", clusterManageQuery);
     createTestCommand("close durable-cq --durable-client-id=client1 --durable-cq-name=cq1",
-        dataManage);
+        clusterManageQuery);
     createTestCommand("show subscription-queue-size --durable-client-id=client1", clusterRead);
     createTestCommand("list durable-cqs --durable-client-id=client1", clusterRead);
 
@@ -160,30 +189,30 @@ public class TestCommand {
     createTestCommand("list functions", clusterRead);
 
     // GfshHelpCommands
-    createTestCommand("hint", null);
-    createTestCommand("help", null);
+    createTestCommand("hint");
+    createTestCommand("help");
 
     // IndexCommands
-    createTestCommand("clear defined indexes", dataManage);
-    createTestCommand("create defined indexes", dataManage);
+    createTestCommand("clear defined indexes", clusterManageQuery);
+    createTestCommand("create defined indexes", clusterManageQuery);
     createTestCommand(
         "create index --name=myKeyIndex --expression=region1.Id --region=RegionA --type=key",
-        regionAManage);
+        clusterManageQuery);
     createTestCommand("define index --name=myIndex1 --expression=exp1 --region=/RegionA",
-        regionAManage);
-    createTestCommand("destroy index --member=server2", dataManage);
-    createTestCommand("destroy index --region=RegionA --member=server2", regionAManage);
-    createTestCommand("list indexes", clusterRead);
+        clusterManageQuery);
+    createTestCommand("destroy index --member=server2", clusterManageQuery);
+    createTestCommand("destroy index --region=RegionA --member=server2", clusterManageQuery);
+    createTestCommand("list indexes", clusterReadQuery);
 
     // LauncherLifecycleCommands
-    createTestCommand("start jconsole", null);
-    createTestCommand("start jvisualvm", null);
-    createTestCommand("start locator --name=locator1", null);
-    createTestCommand("start pulse", null);
-    createTestCommand("start server --name=server1", null);
-    createTestCommand("start vsd", null);
-    createTestCommand("status locator", null);
-    createTestCommand("status server", null);
+    createTestCommand("start jconsole");
+    createTestCommand("start jvisualvm");
+    createTestCommand("start locator --name=locator1");
+    createTestCommand("start pulse");
+    createTestCommand("start server --name=server1");
+    createTestCommand("start vsd");
+    createTestCommand("status locator");
+    createTestCommand("status server");
     // createTestCommand("stop locator --name=locator1", clusterManage);
     // createTestCommand("stop server --name=server1", clusterManage);
 
@@ -203,48 +232,52 @@ public class TestCommand {
 
 
     // PDX Commands
-    createTestCommand("configure pdx --read-serialized=true", dataManage);
-    // createTestCommand("pdx rename --old=org.apache --new=com.pivotal --disk-store=ds1
-    // --disk-dirs=/diskDir1", dataManage);
+    createTestCommand("configure pdx --read-serialized=true", clusterManage);
+    createTestCommand(
+        "pdx rename --old=org.apache --new=com.pivotal --disk-store=ds1 --disk-dirs=/diskDir1");
 
     // Queue Commands
     createTestCommand("create async-event-queue --id=myAEQ --listener=myApp.myListener",
-        dataManage);
+        clusterManageJar);
+    createTestCommand(
+        "create async-event-queue --id=myAEQ --listener=myApp.myListener --persistent",
+        clusterManageJar, clusterWriteDisk);
+
     createTestCommand("list async-event-queues", clusterRead);
 
     // RegionCommands
     createTestCommand("describe region --name=value", clusterRead);
-    createTestCommand("list regions", dataRead);
+    createTestCommand("list regions", clusterRead);
 
     // StatusCommands
     createTestCommand("status cluster-config-service", clusterRead);
 
     // Shell Commands
-    createTestCommand("connect", null);
-    createTestCommand("debug --state=on", null);
-    createTestCommand("describe connection", null);
-    createTestCommand("echo --string=\"Hello World!\"", null);
-    createTestCommand("version", null);
-    createTestCommand("sleep", null);
-    createTestCommand("sh ls", null);
+    createTestCommand("connect");
+    createTestCommand("debug --state=on");
+    createTestCommand("describe connection");
+    createTestCommand("echo --string=\"Hello World!\"");
+    createTestCommand("version");
+    createTestCommand("sleep");
+    createTestCommand("sh ls");
 
     // WAN Commands
     createTestCommand("create gateway-sender --id=sender1 --remote-distributed-system-id=2",
-        dataManage);
-    createTestCommand("start gateway-sender --id=sender1", dataManage);
-    createTestCommand("pause gateway-sender --id=sender1", dataManage);
-    createTestCommand("resume gateway-sender --id=sender1", dataManage);
-    createTestCommand("stop gateway-sender --id=sender1", dataManage);
-    createTestCommand("load-balance gateway-sender --id=sender1", dataManage);
+        clusterManageGateway);
+    createTestCommand("start gateway-sender --id=sender1", clusterManageGateway);
+    createTestCommand("pause gateway-sender --id=sender1", clusterManageGateway);
+    createTestCommand("resume gateway-sender --id=sender1", clusterManageGateway);
+    createTestCommand("stop gateway-sender --id=sender1", clusterManageGateway);
+    createTestCommand("load-balance gateway-sender --id=sender1", clusterManageGateway);
     createTestCommand("list gateways", clusterRead);
-    createTestCommand("create gateway-receiver", dataManage);
-    createTestCommand("start gateway-receiver", dataManage);
-    createTestCommand("stop gateway-receiver", dataManage);
+    createTestCommand("create gateway-receiver", clusterManageGateway);
+    createTestCommand("start gateway-receiver", clusterManageGateway);
+    createTestCommand("stop gateway-receiver", clusterManageGateway);
     createTestCommand("status gateway-receiver", clusterRead);
     createTestCommand("status gateway-sender --id=sender1", clusterRead);
 
     // ShellCommand
-    createTestCommand("disconnect", null);
+    createTestCommand("disconnect");
 
     // Misc commands
     // createTestCommand("shutdown", clusterManage);

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
index dcdc5c4..62ae2e2 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
@@ -20,13 +20,6 @@ import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_P
 import static org.apache.geode.distributed.ConfigurationProperties.NAME;
 import static org.apache.geode.test.dunit.Host.getHost;
 
-import org.apache.geode.internal.AvailablePortHelper;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.dunit.standalone.DUnitLauncher;
-import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
-import org.junit.rules.ExternalResource;
-import org.junit.rules.TemporaryFolder;
-
 import java.io.File;
 import java.io.IOException;
 import java.io.Serializable;
@@ -34,6 +27,14 @@ import java.util.Arrays;
 import java.util.Objects;
 import java.util.Properties;
 
+import org.junit.rules.ExternalResource;
+import org.junit.rules.TemporaryFolder;
+
+import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.standalone.DUnitLauncher;
+import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
+
 
 /**
  * A rule to help you start locators and servers inside of a
@@ -118,6 +119,10 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
 
   public MemberVM startServerAsJmxManager(int index) throws IOException {
     Properties properties = new Properties();
+    return startServerAsJmxManager(index, properties);
+  }
+
+  public MemberVM startServerAsJmxManager(int index, Properties properties) throws IOException {
     properties.setProperty(JMX_MANAGER_PORT, AvailablePortHelper.getRandomAvailableTCPPort() + "");
     return startServerVM(index, properties, -1);
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
index 008ced7..5b4f2c1 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
@@ -38,6 +38,12 @@ import java.io.File;
 import java.io.IOException;
 import java.util.Properties;
 
+import org.junit.rules.ExternalResource;
+import org.junit.rules.TemporaryFolder;
+
+import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.security.SecurityManager;
+
 /**
  * the abstract class that's used by LocatorStarterRule and ServerStarterRule to avoid code
  * duplication.

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/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 28c6c8a..135f509 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
@@ -533,8 +533,8 @@ org/apache/geode/management/internal/cli/functions/AsyncEventQueueFunctionArgs,t
 org/apache/geode/management/internal/cli/functions/ChangeLogLevelFunction,true,1
 org/apache/geode/management/internal/cli/functions/CloseDurableClientFunction,true,1
 org/apache/geode/management/internal/cli/functions/CloseDurableCqFunction,true,1
-org/apache/geode/management/internal/cli/functions/ContunuousQueryFunction,true,1
-org/apache/geode/management/internal/cli/functions/ContunuousQueryFunction$ClientInfo,true,1,isDurable:java/lang/String,primaryServer:java/lang/String,secondaryServer:java/lang/String,this$0:org/apache/geode/management/internal/cli/functions/ContunuousQueryFunction
+org/apache/geode/management/internal/cli/functions/ContinuousQueryFunction,true,1
+org/apache/geode/management/internal/cli/functions/ContinuousQueryFunction$ClientInfo,true,1,isDurable:java/lang/String,primaryServer:java/lang/String,secondaryServer:java/lang/String,this$0:org/apache/geode/management/internal/cli/functions/ContinuousQueryFunction
 org/apache/geode/management/internal/cli/functions/CreateAsyncEventQueueFunction,true,1
 org/apache/geode/management/internal/cli/functions/CreateDefinedIndexesFunction,true,1
 org/apache/geode/management/internal/cli/functions/CreateDiskStoreFunction,true,1

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-cq/src/test/java/org/apache/geode/management/internal/cli/commands/ClientCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/org/apache/geode/management/internal/cli/commands/ClientCommandsDUnitTest.java b/geode-cq/src/test/java/org/apache/geode/management/internal/cli/commands/ClientCommandsDUnitTest.java
index 7dd92bf..b0552ad 100644
--- a/geode-cq/src/test/java/org/apache/geode/management/internal/cli/commands/ClientCommandsDUnitTest.java
+++ b/geode-cq/src/test/java/org/apache/geode/management/internal/cli/commands/ClientCommandsDUnitTest.java
@@ -14,8 +14,45 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import org.apache.geode.cache.*;
-import org.apache.geode.cache.client.*;
+import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_NETWORK_PARTITION_DETECTION;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_ARCHIVE_FILE;
+import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_SAMPLING_ENABLED;
+import static org.apache.geode.test.dunit.Assert.assertEquals;
+import static org.apache.geode.test.dunit.Assert.assertNotNull;
+import static org.apache.geode.test.dunit.Assert.assertTrue;
+import static org.apache.geode.test.dunit.DistributedTestUtils.getDUnitLocatorPort;
+import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
+import static org.apache.geode.test.dunit.NetworkUtils.getServerHostName;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import javax.management.ObjectName;
+
+import org.awaitility.Awaitility;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.AttributesFactory;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.DataPolicy;
+import org.apache.geode.cache.PartitionAttributesFactory;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.Scope;
+import org.apache.geode.cache.client.ClientCache;
+import org.apache.geode.cache.client.ClientCacheFactory;
+import org.apache.geode.cache.client.ClientRegionFactory;
+import org.apache.geode.cache.client.ClientRegionShortcut;
+import org.apache.geode.cache.client.PoolManager;
 import org.apache.geode.cache.client.internal.PoolImpl;
 import org.apache.geode.cache.query.CqAttributesFactory;
 import org.apache.geode.cache.query.QueryService;
@@ -40,27 +77,10 @@ import org.apache.geode.management.internal.cli.result.CompositeResultData.Secti
 import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.test.dunit.Host;
 import org.apache.geode.test.dunit.SerializableCallable;
+import org.apache.geode.test.dunit.SerializableRunnableIF;
 import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
-import org.awaitility.Awaitility;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import javax.management.ObjectName;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.apache.geode.test.dunit.Assert.*;
-import static org.apache.geode.test.dunit.DistributedTestUtils.getDUnitLocatorPort;
-import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
-import static org.apache.geode.test.dunit.NetworkUtils.getServerHostName;
 
 /**
  * Dunit class for testing gemfire Client commands : list client , describe client
@@ -88,35 +108,34 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
 
     assertNotNull(serverMember);
 
-    manager.invoke(() -> {
-      Awaitility.waitAtMost(2 * 60, TimeUnit.SECONDS).pollDelay(2, TimeUnit.SECONDS).until(() -> {
-        final SystemManagementService service =
-            (SystemManagementService) ManagementService.getManagementService(getCache());
-        if (service == null) {
-          getLogWriter().info("waitForListClientMbean Still probing for service");
-          return false;
-        } else {
-          final ObjectName cacheServerMBeanName =
-              service.getCacheServerMBeanName(port0, serverMember);
-          CacheServerMXBean bean =
-              service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
-          try {
-            if (bean != null) {
-              if (bean.getClientIds().length > 1) {
-                return true;
+    manager.invoke(() -> Awaitility.waitAtMost(2 * 60, TimeUnit.SECONDS)
+        .pollDelay(2, TimeUnit.SECONDS).until(() -> {
+          final SystemManagementService service =
+              (SystemManagementService) ManagementService.getManagementService(getCache());
+          if (service == null) {
+            getLogWriter().info("waitForListClientMbean Still probing for service");
+            return false;
+          } else {
+            final ObjectName cacheServerMBeanName =
+                service.getCacheServerMBeanName(port0, serverMember);
+            CacheServerMXBean bean =
+                service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
+            try {
+              if (bean != null) {
+                if (bean.getClientIds().length > 1) {
+                  return true;
+                }
               }
+              return false;
+
+            } catch (Exception e) {
+              LogWrapper.getInstance()
+                  .warning("waitForListClientMbean Exception in waitForListClientMbean ::: "
+                      + CliUtil.stackTraceAsString(e));
             }
             return false;
-
-          } catch (Exception e) {
-            LogWrapper.getInstance()
-                .warning("waitForListClientMbean Exception in waitForListClientMbean ::: "
-                    + CliUtil.stackTraceAsString(e));
           }
-          return false;
-        }
-      });
-    });
+        }));
   }
 
   public void waitForMbean() {
@@ -128,44 +147,41 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
 
     assertNotNull(serverMember);
 
-    manager.invoke(() -> {
-      Awaitility.waitAtMost(2 * 60, TimeUnit.SECONDS).pollDelay(2, TimeUnit.SECONDS).until(() -> {
-        final SystemManagementService service =
-            (SystemManagementService) ManagementService.getManagementService(getCache());
-        if (service == null) {
-          getLogWriter().info("waitForMbean Still probing for service");
-          return false;
-        } else {
-          final ObjectName cacheServerMBeanName =
-              service.getCacheServerMBeanName(port0, serverMember);
-          CacheServerMXBean bean =
-              service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
-          try {
-            ClientHealthStatus stats = bean.showClientStats(bean.getClientIds()[0]);
-            Map<String, String> poolStats = stats.getPoolStats();
-            if (poolStats.size() > 0) {
-              Iterator<Entry<String, String>> it = poolStats.entrySet().iterator();
-              while (it.hasNext()) {
-                Entry<String, String> entry = it.next();
-                String poolStatsStr = entry.getValue();
-                String str[] = poolStatsStr.split(";");
-                int numCqs = Integer.parseInt(str[3].substring(str[3].indexOf("=") + 1));
-                if (numCqs == 3) {
-                  return true;
+    manager.invoke(() -> Awaitility.waitAtMost(2 * 60, TimeUnit.SECONDS)
+        .pollDelay(2, TimeUnit.SECONDS).until(() -> {
+          final SystemManagementService service =
+              (SystemManagementService) ManagementService.getManagementService(getCache());
+          if (service == null) {
+            getLogWriter().info("waitForMbean Still probing for service");
+            return false;
+          } else {
+            final ObjectName cacheServerMBeanName =
+                service.getCacheServerMBeanName(port0, serverMember);
+            CacheServerMXBean bean =
+                service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
+            try {
+              ClientHealthStatus stats = bean.showClientStats(bean.getClientIds()[0]);
+              Map<String, String> poolStats = stats.getPoolStats();
+              if (poolStats.size() > 0) {
+                for (Entry<String, String> entry : poolStats.entrySet()) {
+                  String poolStatsStr = entry.getValue();
+                  String str[] = poolStatsStr.split(";");
+                  int numCqs = Integer.parseInt(str[3].substring(str[3].indexOf("=") + 1));
+                  if (numCqs == 3) {
+                    return true;
+                  }
                 }
               }
+              return false;
+
+            } catch (Exception e) {
+              LogWrapper.getInstance().warning(
+                  "waitForMbean Exception in waitForMbean ::: " + CliUtil.stackTraceAsString(e));
             }
             return false;
 
-          } catch (Exception e) {
-            LogWrapper.getInstance().warning(
-                "waitForMbean Exception in waitForMbean ::: " + CliUtil.stackTraceAsString(e));
           }
-          return false;
-
-        }
-      });
-    });
+        }));
   }
 
   public void waitForListClientMbean3() {
@@ -179,59 +195,56 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
 
     assertNotNull(serverMember1);
 
-    manager.invoke(() -> {
-      Awaitility.waitAtMost(2 * 60, TimeUnit.SECONDS).pollDelay(2, TimeUnit.SECONDS).until(() -> {
-        final SystemManagementService service =
-            (SystemManagementService) ManagementService.getManagementService(getCache());
-        if (service == null) {
-          getLogWriter().info("waitForListClientMbean3 Still probing for service");
-          return false;
-        } else {
-          final ObjectName cacheServerMBeanName1 =
-              service.getCacheServerMBeanName(port0, serverMember1);
-          final ObjectName cacheServerMBeanName2 =
-              service.getCacheServerMBeanName(port1, serverMember2);
-          CacheServerMXBean bean1 =
-              service.getMBeanProxy(cacheServerMBeanName1, CacheServerMXBean.class);
-          CacheServerMXBean bean2 =
-              service.getMBeanProxy(cacheServerMBeanName2, CacheServerMXBean.class);
-          try {
-            if (bean1 != null && bean2 != null) {
-              if (bean1.getClientIds().length > 0 && bean2.getClientIds().length > 0) {
-                return true;
+    manager.invoke(() -> Awaitility.waitAtMost(2 * 60, TimeUnit.SECONDS)
+        .pollDelay(2, TimeUnit.SECONDS).until(() -> {
+          final SystemManagementService service =
+              (SystemManagementService) ManagementService.getManagementService(getCache());
+          if (service == null) {
+            getLogWriter().info("waitForListClientMbean3 Still probing for service");
+            return false;
+          } else {
+            final ObjectName cacheServerMBeanName1 =
+                service.getCacheServerMBeanName(port0, serverMember1);
+            final ObjectName cacheServerMBeanName2 =
+                service.getCacheServerMBeanName(port1, serverMember2);
+            CacheServerMXBean bean1 =
+                service.getMBeanProxy(cacheServerMBeanName1, CacheServerMXBean.class);
+            CacheServerMXBean bean2 =
+                service.getMBeanProxy(cacheServerMBeanName2, CacheServerMXBean.class);
+            try {
+              if (bean1 != null && bean2 != null) {
+                if (bean1.getClientIds().length > 0 && bean2.getClientIds().length > 0) {
+                  return true;
+                }
               }
+              return false;
+
+            } catch (Exception e) {
+              LogWrapper.getInstance()
+                  .warning("waitForListClientMbean3 Exception in waitForListClientMbean ::: "
+                      + CliUtil.stackTraceAsString(e));
             }
             return false;
-
-          } catch (Exception e) {
-            LogWrapper.getInstance()
-                .warning("waitForListClientMbean3 Exception in waitForListClientMbean ::: "
-                    + CliUtil.stackTraceAsString(e));
           }
-          return false;
-        }
-      });
-    });
+        }));
   }
 
   @Ignore("disabled for unknown reason")
   @Test
   public void testDescribeClientWithServers3() throws Exception {
     setupSystem3();
-    String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID
-        + "=\"" + clientId + "\"";
+    String commandString;
     final VM server1 = Host.getHost(0).getVM(1);
     final VM server2 = Host.getHost(0).getVM(3);
     final VM manager = Host.getHost(0).getVM(0);
     String serverName1 =
-        (String) server1.invoke("get DistributedMemberID ", () -> getDistributedMemberId());
+        (String) server1.invoke("get DistributedMemberID ", this::getDistributedMemberId);
 
-    String serverName2 =
-        (String) server2.invoke("get DistributedMemberID ", () -> getDistributedMemberId());
+    String serverName2 = server2.invoke("get DistributedMemberID ", this::getDistributedMemberId);
 
     final DistributedMember serverMember1 = getMember(server1);
 
-    String[] clientIds = (String[]) manager.invoke("get Client Ids", () -> {
+    String[] clientIds = manager.invoke("get Client Ids", () -> {
       final SystemManagementService service =
           (SystemManagementService) ManagementService.getManagementService(getCache());
 
@@ -250,7 +263,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
 
     final DistributedMember serverMember2 = getMember(server2);
 
-    String[] clientIds2 = (String[]) manager.invoke("get Client Ids", () -> {
+    String[] clientIds2 = manager.invoke("get Client Ids", () -> {
       final SystemManagementService service =
           (SystemManagementService) ManagementService.getManagementService(getCache());
 
@@ -307,21 +320,21 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
     SectionResultData section = resultData.retrieveSection("InfoSection");
     assertNotNull(section);
     for (int i = 0; i < 1; i++) {
-      TabularResultData tableRsultData = section.retrieveTableByIndex(i);
-      getLogWriter().info("testDescribeClientWithServers getHeader=" + tableRsultData.getHeader());
-      assertNotNull(tableRsultData);
+      TabularResultData tableResultData = section.retrieveTableByIndex(i);
+      getLogWriter().info("testDescribeClientWithServers getHeader=" + tableResultData.getHeader());
+      assertNotNull(tableResultData);
 
-      List<String> minConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
-      List<String> maxConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
-      List<String> redudancy =
-          tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUDANCY);
-      List<String> numCqs = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_CQs);
+      List<String> minConn = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
+      List<String> maxConn = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
+      List<String> redundancy =
+          tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUNDANCY);
+      List<String> numCqs = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_CQs);
 
       getLogWriter().info("testDescribeClientWithServers getHeader numCqs =" + numCqs);
 
       assertTrue(minConn.contains("1"));
       assertTrue(maxConn.contains("-1"));
-      assertTrue(redudancy.contains("1"));
+      assertTrue(redundancy.contains("1"));
       assertTrue(numCqs.contains("3"));
       String puts = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PUTS);
       assertTrue(puts.equals("2"));
@@ -358,8 +371,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
     getLogWriter().info("testDescribeClient commandStr=" + commandString);
 
     final VM server1 = Host.getHost(0).getVM(1);
-    String serverName =
-        (String) server1.invoke("get distributed member Id", () -> getDistributedMemberId());
+    String serverName = server1.invoke("get distributed member Id", this::getDistributedMemberId);
 
     CommandResult commandResult = executeCommand(commandString);
     getLogWriter().info("testDescribeClient commandResult=" + commandResult);
@@ -371,17 +383,18 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
     CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
     SectionResultData section = resultData.retrieveSection("InfoSection");
     assertNotNull(section);
-    TabularResultData tableRsultData = section.retrieveTable("Pool Stats For Pool Name = DEFAULT");
-    assertNotNull(tableRsultData);
+    TabularResultData tableResultData = section.retrieveTable("Pool Stats For Pool Name = DEFAULT");
+    assertNotNull(tableResultData);
 
-    List<String> minConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
-    List<String> maxConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
-    List<String> redudancy = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUDANCY);
-    List<String> numCqs = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_CQs);
+    List<String> minConn = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
+    List<String> maxConn = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
+    List<String> redundancy =
+        tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUNDANCY);
+    List<String> numCqs = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_CQs);
 
     assertTrue(minConn.contains("1"));
     assertTrue(maxConn.contains("-1"));
-    assertTrue(redudancy.contains("1"));
+    assertTrue(redundancy.contains("1"));
     assertTrue(numCqs.contains("3"));
     String puts = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PUTS);
     assertTrue(puts.equals("2"));
@@ -417,8 +430,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
     getLogWriter().info("testDescribeClientWithServers commandStr=" + commandString);
 
     final VM server1 = Host.getHost(0).getVM(1);
-    String serverName =
-        (String) server1.invoke("get Distributed Member Id", () -> getDistributedMemberId());
+    String serverName = server1.invoke("get Distributed Member Id", this::getDistributedMemberId);
 
     CommandResult commandResult = executeCommand(commandString);
     getLogWriter().info("testDescribeClientWithServers commandResult=" + commandResult);
@@ -430,17 +442,18 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
     CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
     SectionResultData section = resultData.retrieveSection("InfoSection");
     assertNotNull(section);
-    TabularResultData tableRsultData = section.retrieveTable("Pool Stats For Pool Name = DEFAULT");
-    assertNotNull(tableRsultData);
+    TabularResultData tableResultData = section.retrieveTable("Pool Stats For Pool Name = DEFAULT");
+    assertNotNull(tableResultData);
 
-    List<String> minConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
-    List<String> maxConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
-    List<String> redudancy = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUDANCY);
-    List<String> numCqs = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_CQs);
+    List<String> minConn = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
+    List<String> maxConn = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
+    List<String> redundancy =
+        tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUNDANCY);
+    List<String> numCqs = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_CQs);
 
     assertTrue(minConn.contains("1"));
     assertTrue(maxConn.contains("-1"));
-    assertTrue(redudancy.contains("1"));
+    assertTrue(redundancy.contains("1"));
     assertTrue(numCqs.contains("3"));
     String puts = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PUTS);
     assertTrue(puts.equals("2"));
@@ -483,7 +496,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
 
     final DistributedMember serverMember = getMember(server1);
 
-    String[] clientIds = (String[]) manager.invoke("get client Ids", () -> {
+    String[] clientIds = manager.invoke("get client Ids", () -> {
       final SystemManagementService service =
           (SystemManagementService) ManagementService.getManagementService(getCache());
       final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
@@ -491,8 +504,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
       return bean.getClientIds();
     });
 
-    String serverName =
-        (String) server1.invoke("get distributed member Id", () -> getDistributedMemberId());
+    String serverName = server1.invoke("get distributed member Id", this::getDistributedMemberId);
 
     CommandResult commandResult = executeCommand(commandString);
     getLogWriter().info("testListClient commandResult=" + commandResult);
@@ -504,13 +516,13 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
     CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
     SectionResultData section = resultData.retrieveSection("section1");
     assertNotNull(section);
-    TabularResultData tableRsultData = section.retrieveTable("TableForClientList");
-    assertNotNull(tableRsultData);
+    TabularResultData tableResultData = section.retrieveTable("TableForClientList");
+    assertNotNull(tableResultData);
 
     List<String> serverNames =
-        tableRsultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_SERVERS);
+        tableResultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_SERVERS);
     List<String> clientNames =
-        tableRsultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_Clients);
+        tableResultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_Clients);
 
     getLogWriter().info("testListClients serverNames : " + serverNames);
     getLogWriter().info("testListClients clientNames : " + clientNames);
@@ -543,7 +555,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
 
     final DistributedMember serverMember = getMember(server1);
 
-    String[] clientIds = (String[]) manager.invoke("get client Ids", () -> {
+    String[] clientIds = manager.invoke("get client Ids", () -> {
       final SystemManagementService service =
           (SystemManagementService) ManagementService.getManagementService(getCache());
       final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
@@ -551,11 +563,9 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
       return bean.getClientIds();
     });
 
-    String serverName1 =
-        (String) server1.invoke("get distributed member Id", () -> getDistributedMemberId());
+    String serverName1 = server1.invoke("get distributed member Id", this::getDistributedMemberId);
 
-    String serverName2 =
-        (String) server2.invoke("get distributed member Id", () -> getDistributedMemberId());
+    String serverName2 = server2.invoke("get distributed member Id", this::getDistributedMemberId);
 
     CommandResult commandResult = executeCommand(commandString);
     System.out.println("testListClientForServers commandResult=" + commandResult);
@@ -567,13 +577,13 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
     CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
     SectionResultData section = resultData.retrieveSection("section1");
     assertNotNull(section);
-    TabularResultData tableRsultData = section.retrieveTable("TableForClientList");
-    assertNotNull(tableRsultData);
+    TabularResultData tableResultData = section.retrieveTable("TableForClientList");
+    assertNotNull(tableResultData);
 
     List<String> serverNames =
-        tableRsultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_SERVERS);
+        tableResultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_SERVERS);
     List<String> clientNames =
-        tableRsultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_Clients);
+        tableResultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_Clients);
 
     serverName1 = serverName1.replace(":", "-");
     serverName2 = serverName2.replace(":", "-");
@@ -602,7 +612,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
   }
 
   public DistributedMember getMember(final VM vm) {
-    return (DistributedMember) vm.invoke("Get Member",
+    return vm.invoke("Get Member",
         () -> GemFireCacheImpl.getInstance().getDistributedSystem().getDistributedMember());
   }
 
@@ -635,7 +645,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
     setupCqsOnVM(client1);
     waitForMbean();
 
-    clientId = (String) manager.invoke("get client Id", () -> {
+    clientId = manager.invoke("get client Id", () -> {
       Cache cache = GemFireCacheImpl.getInstance();
       SystemManagementService service =
           (SystemManagementService) ManagementService.getExistingManagementService(cache);
@@ -664,7 +674,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
 
     waitForMbean();
 
-    clientId = (String) manager.invoke("get client Id", () -> {
+    clientId = manager.invoke("get client Id", () -> {
       Cache cache = GemFireCacheImpl.getInstance();
       SystemManagementService service =
           (SystemManagementService) ManagementService.getExistingManagementService(cache);
@@ -692,7 +702,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
     setupCqsOnVM(client1);
     waitForListClientMbean3();
 
-    clientId = (String) manager.invoke("get client Id", () -> {
+    clientId = manager.invoke("get client Id", () -> {
       Cache cache = GemFireCacheImpl.getInstance();
       SystemManagementService service =
           (SystemManagementService) ManagementService.getExistingManagementService(cache);
@@ -725,7 +735,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
   }
 
   private int startCacheServer(VM server, final int port, final boolean createPR,
-      final String regionName) throws Exception {
+      final String regionName) {
 
     return server.invoke("setup CacheServer", () -> {
       getSystem(getServerProperties());
@@ -775,7 +785,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
         ccf.setPoolSubscriptionRedundancy(1);
         ccf.setPoolMinConnections(1);
 
-        ClientCache clientCache = (ClientCache) getClientCache(ccf);
+        ClientCache clientCache = getClientCache(ccf);
         // Create region
         if (clientCache.getRegion(Region.SEPARATOR + regionName) == null
             && clientCache.getRegion(regionName) == null) {
@@ -813,9 +823,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
 
   private void closeCacheServer(final VM vm) {
     vm.invoke("Stop client", () -> {
-      Iterator<CacheServer> it = CacheFactory.getAnyInstance().getCacheServers().iterator();
-      while (it.hasNext()) {
-        CacheServer cacheServer = it.next();
+      for (CacheServer cacheServer : CacheFactory.getAnyInstance().getCacheServers()) {
         cacheServer.stop();
       }
     });
@@ -841,35 +849,34 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
     final DistributedMember serverMember = getMember(server1);
     assertNotNull(serverMember);
 
-    manager.invoke(() -> {
-      Awaitility.waitAtMost(5 * 60, TimeUnit.SECONDS).pollDelay(2, TimeUnit.SECONDS).until(() -> {
-        try {
-          final SystemManagementService service =
-              (SystemManagementService) ManagementService.getManagementService(getCache());
-          if (service == null) {
-            getLogWriter().info("waitForNonSubScribedClientMBean Still probing for service");
-            return false;
-          } else {
-            getLogWriter().info("waitForNonSubScribedClientMBean 1");
-            final ObjectName cacheServerMBeanName =
-                service.getCacheServerMBeanName(port0, serverMember);
-            getLogWriter().info(
-                "waitForNonSubScribedClientMBean 2 cacheServerMBeanName " + cacheServerMBeanName);
-            CacheServerMXBean bean =
-                service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
-            getLogWriter().info("waitForNonSubScribedClientMBean 2 bean " + bean);
-            if (bean.getClientIds().length > 0) {
-              return true;
+    manager.invoke(() -> Awaitility.waitAtMost(5 * 60, TimeUnit.SECONDS)
+        .pollDelay(2, TimeUnit.SECONDS).until(() -> {
+          try {
+            final SystemManagementService service =
+                (SystemManagementService) ManagementService.getManagementService(getCache());
+            if (service == null) {
+              getLogWriter().info("waitForNonSubScribedClientMBean Still probing for service");
+              return false;
+            } else {
+              getLogWriter().info("waitForNonSubScribedClientMBean 1");
+              final ObjectName cacheServerMBeanName =
+                  service.getCacheServerMBeanName(port0, serverMember);
+              getLogWriter().info(
+                  "waitForNonSubScribedClientMBean 2 cacheServerMBeanName " + cacheServerMBeanName);
+              CacheServerMXBean bean =
+                  service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
+              getLogWriter().info("waitForNonSubScribedClientMBean 2 bean " + bean);
+              if (bean.getClientIds().length > 0) {
+                return true;
+              }
             }
+          } catch (Exception e) {
+            LogWrapper.getInstance()
+                .warning("waitForNonSubScribedClientMBean Exception in waitForMbean ::: "
+                    + CliUtil.stackTraceAsString(e));
           }
-        } catch (Exception e) {
-          LogWrapper.getInstance()
-              .warning("waitForNonSubScribedClientMBean Exception in waitForMbean ::: "
-                  + CliUtil.stackTraceAsString(e));
-        }
-        return false;
-      });
-    });
+          return false;
+        }));
   }
 
   public void waitForMixedClients() {
@@ -881,34 +888,33 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
 
     assertNotNull(serverMember);
 
-    manager.invoke(() -> {
-      Awaitility.waitAtMost(5 * 60, TimeUnit.SECONDS).pollDelay(2, TimeUnit.SECONDS).until(() -> {
-        try {
-          final SystemManagementService service =
-              (SystemManagementService) ManagementService.getManagementService(getCache());
-          if (service == null) {
-            getLogWriter().info("waitForMixedClients Still probing for service");
-            return false;
-          } else {
-            getLogWriter().info("waitForMixedClients 1");
-            final ObjectName cacheServerMBeanName =
-                service.getCacheServerMBeanName(port0, serverMember);
-            getLogWriter()
-                .info("waitForMixedClients 2 cacheServerMBeanName " + cacheServerMBeanName);
-            CacheServerMXBean bean =
-                service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
-            getLogWriter().info("waitForMixedClients 2 bean " + bean);
-            if (bean.getClientIds().length > 1) {
-              return true;
+    manager.invoke(() -> Awaitility.waitAtMost(5 * 60, TimeUnit.SECONDS)
+        .pollDelay(2, TimeUnit.SECONDS).until(() -> {
+          try {
+            final SystemManagementService service =
+                (SystemManagementService) ManagementService.getManagementService(getCache());
+            if (service == null) {
+              getLogWriter().info("waitForMixedClients Still probing for service");
+              return false;
+            } else {
+              getLogWriter().info("waitForMixedClients 1");
+              final ObjectName cacheServerMBeanName =
+                  service.getCacheServerMBeanName(port0, serverMember);
+              getLogWriter()
+                  .info("waitForMixedClients 2 cacheServerMBeanName " + cacheServerMBeanName);
+              CacheServerMXBean bean =
+                  service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
+              getLogWriter().info("waitForMixedClients 2 bean " + bean);
+              if (bean.getClientIds().length > 1) {
+                return true;
+              }
             }
+          } catch (Exception e) {
+            LogWrapper.getInstance().warning("waitForMixedClients Exception in waitForMbean ::: "
+                + CliUtil.stackTraceAsString(e));
           }
-        } catch (Exception e) {
-          LogWrapper.getInstance().warning(
-              "waitForMixedClients Exception in waitForMbean ::: " + CliUtil.stackTraceAsString(e));
-        }
-        return false;
-      });
-    });
+          return false;
+        }));
   }
 
   @Category(FlakyTest.class) // GEODE-910: random ports, HeadlessGfsh
@@ -934,16 +940,17 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
     CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
     SectionResultData section = resultData.retrieveSection("InfoSection");
     assertNotNull(section);
-    TabularResultData tableRsultData = section.retrieveTable("Pool Stats For Pool Name = DEFAULT");
-    assertNotNull(tableRsultData);
+    TabularResultData tableResultData = section.retrieveTable("Pool Stats For Pool Name = DEFAULT");
+    assertNotNull(tableResultData);
 
-    List<String> minConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
-    List<String> maxConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
-    List<String> redudancy = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUDANCY);
+    List<String> minConn = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
+    List<String> maxConn = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
+    List<String> redundancy =
+        tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUNDANCY);
 
     assertTrue(minConn.contains("1"));
     assertTrue(maxConn.contains("-1"));
-    assertTrue(redudancy.contains("1"));
+    assertTrue(redundancy.contains("1"));
 
     String puts = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PUTS);
     assertTrue(puts.equals("2"));
@@ -980,8 +987,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
     String[] clientIds = setupSystemWithSubAndNonSubClient();
 
     final VM server1 = Host.getHost(0).getVM(1);
-    String serverName =
-        (String) server1.invoke("Get DistributedMember Id", () -> getDistributedMemberId());
+    String serverName = server1.invoke("Get DistributedMember Id", this::getDistributedMemberId);
 
     String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID
         + "=\"" + clientIds[0] + "\"";
@@ -1018,12 +1024,12 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
 
     List<String> minConn = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
     List<String> maxConn = tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
-    List<String> redudancy =
-        tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUDANCY);
+    List<String> redundancy =
+        tableResultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUNDANCY);
 
     assertTrue(minConn.contains("1"));
     assertTrue(maxConn.contains("-1"));
-    assertTrue(redudancy.contains("1"));
+    assertTrue(redundancy.contains("1"));
 
     String puts = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PUTS);
     assertTrue(puts.equals("2"));
@@ -1098,7 +1104,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
 
     waitForMixedClients();
 
-    String[] cliendIds = (String[]) manager.invoke("get client Ids", () -> {
+    String[] clientIds = manager.invoke("get client Ids", () -> {
       Cache cache = GemFireCacheImpl.getInstance();
       SystemManagementService service =
           (SystemManagementService) ManagementService.getExistingManagementService(cache);
@@ -1108,7 +1114,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
       return bean.getClientIds();
     });
 
-    return cliendIds;
+    return clientIds;
   }
 
   private void startNonSubscribedClient(VM client, final VM server, final int port) {
@@ -1132,7 +1138,7 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
         ccf.setPoolSubscriptionRedundancy(1);
         ccf.setPoolMinConnections(1);
 
-        ClientCache clientCache = (ClientCache) getClientCache(ccf);
+        ClientCache clientCache = getClientCache(ccf);
         // Create region
         if (clientCache.getRegion(Region.SEPARATOR + regionName) == null
             && clientCache.getRegion(regionName) == null) {
@@ -1165,9 +1171,9 @@ public class ClientCommandsDUnitTest extends CliCommandTestBase {
 
   @Override
   public final void postTearDownCacheTestCase() throws Exception {
-    Host.getHost(0).getVM(0).invoke(() -> CacheServerTestUtil.closeCache());
-    Host.getHost(0).getVM(1).invoke(() -> CacheServerTestUtil.closeCache());
-    Host.getHost(0).getVM(2).invoke(() -> CacheServerTestUtil.closeCache());
-    Host.getHost(0).getVM(3).invoke(() -> CacheServerTestUtil.closeCache());
+    Host.getHost(0).getVM(0).invoke((SerializableRunnableIF) CacheServerTestUtil::closeCache);
+    Host.getHost(0).getVM(1).invoke((SerializableRunnableIF) CacheServerTestUtil::closeCache);
+    Host.getHost(0).getVM(2).invoke((SerializableRunnableIF) CacheServerTestUtil::closeCache);
+    Host.getHost(0).getVM(3).invoke((SerializableRunnableIF) CacheServerTestUtil::closeCache);
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/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 00440e5..6ddacf1 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
@@ -14,7 +14,21 @@
  */
 package org.apache.geode.cache.lucene.internal.cli;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
 import org.apache.commons.lang.StringUtils;
+import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.execute.Execution;
@@ -44,19 +58,10 @@ import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
 import org.apache.geode.management.internal.configuration.domain.XmlEntity;
 import org.apache.geode.management.internal.security.ResourceOperation;
+import org.apache.geode.security.GemFireSecurityException;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
+import org.apache.geode.security.ResourcePermission.Target;
 
 /**
  * The LuceneIndexCommands class encapsulates all Geode shell (Gfsh) commands related to Lucene
@@ -81,7 +86,7 @@ public class LuceneIndexCommands implements GfshCommand {
   @CliCommand(value = LuceneCliStrings.LUCENE_LIST_INDEX,
       help = LuceneCliStrings.LUCENE_LIST_INDEX__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
-  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ, target = Target.QUERY)
   public Result listIndex(@CliOption(key = LuceneCliStrings.LUCENE_LIST_INDEX__STATS,
       specifiedDefaultValue = "true", unspecifiedDefaultValue = "false",
       help = LuceneCliStrings.LUCENE_LIST_INDEX__STATS__HELP) final boolean stats) {
@@ -116,7 +121,7 @@ public class LuceneIndexCommands implements GfshCommand {
         (List<Set<LuceneIndexDetails>>) resultsCollector.getResult();
 
     List<LuceneIndexDetails> sortedResults =
-        results.stream().flatMap(set -> set.stream()).sorted().collect(Collectors.toList());
+        results.stream().flatMap(Collection::stream).sorted().collect(Collectors.toList());
     LinkedHashSet<LuceneIndexDetails> uniqResults = new LinkedHashSet<>();
     uniqResults.addAll(sortedResults);
     sortedResults.clear();
@@ -158,10 +163,15 @@ public class LuceneIndexCommands implements GfshCommand {
     }
   }
 
+  /**
+   * On the server, we also verify the resource operation permissions CLUSTER:WRITE:DISK
+   */
   @CliCommand(value = LuceneCliStrings.LUCENE_CREATE_INDEX,
       help = LuceneCliStrings.LUCENE_CREATE_INDEX__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
   // TODO : Add optionContext for indexName
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
   public Result createIndex(@CliOption(key = LuceneCliStrings.LUCENE__INDEX_NAME, mandatory = true,
       help = LuceneCliStrings.LUCENE_CREATE_INDEX__NAME__HELP) final String indexName,
 
@@ -178,12 +188,10 @@ public class LuceneIndexCommands implements GfshCommand {
     Result result;
     XmlEntity xmlEntity = null;
 
-    getCache().getSecurityService().authorizeRegionManage(regionPath);
     try {
       final InternalCache cache = getCache();
       // trim fields for any leading trailing spaces.
-      String[] trimmedFields =
-          Arrays.stream(fields).map(field -> field.trim()).toArray(size -> new String[size]);
+      String[] trimmedFields = Arrays.stream(fields).map(String::trim).toArray(String[]::new);
       LuceneIndexInfo indexInfo =
           new LuceneIndexInfo(indexName, regionPath, trimmedFields, analyzers);
       final ResultCollector<?, ?> rc =
@@ -224,7 +232,7 @@ public class LuceneIndexCommands implements GfshCommand {
   @CliCommand(value = LuceneCliStrings.LUCENE_DESCRIBE_INDEX,
       help = LuceneCliStrings.LUCENE_DESCRIBE_INDEX__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
-  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ, target = Target.QUERY)
   public Result describeIndex(
       @CliOption(key = LuceneCliStrings.LUCENE__INDEX_NAME, mandatory = true,
           help = LuceneCliStrings.LUCENE_DESCRIBE_INDEX__NAME__HELP) final String indexName,
@@ -256,14 +264,15 @@ public class LuceneIndexCommands implements GfshCommand {
     final ResultCollector<?, ?> rc =
         executeFunctionOnRegion(describeIndexFunction, indexInfo, true);
     final List<LuceneIndexDetails> funcResults = (List<LuceneIndexDetails>) rc.getResult();
-    return funcResults.stream().filter(indexDetails -> indexDetails != null)
-        .collect(Collectors.toList());
+    return funcResults.stream().filter(Objects::nonNull).collect(Collectors.toList());
   }
 
+  /**
+   * Internally, we verify the resource operation permissions DATA:READ:[RegionName]
+   */
   @CliCommand(value = LuceneCliStrings.LUCENE_SEARCH_INDEX,
       help = LuceneCliStrings.LUCENE_SEARCH_INDEX__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.WRITE)
   public Result searchIndex(@CliOption(key = LuceneCliStrings.LUCENE__INDEX_NAME, mandatory = true,
       help = LuceneCliStrings.LUCENE_SEARCH_INDEX__NAME__HELP) final String indexName,
 
@@ -284,6 +293,7 @@ public class LuceneIndexCommands implements GfshCommand {
           unspecifiedDefaultValue = "false",
           help = LuceneCliStrings.LUCENE_SEARCH_INDEX__KEYSONLY__HELP) boolean keysOnly) {
     try {
+      getSecurityService().authorizeRegionRead(regionPath);
       LuceneQueryInfo queryInfo =
           new LuceneQueryInfo(indexName, regionPath, queryString, defaultField, limit, keysOnly);
       int pageSize = Integer.MAX_VALUE;
@@ -297,6 +307,8 @@ public class LuceneIndexCommands implements GfshCommand {
       throw e;
     } catch (IllegalArgumentException e) {
       return ResultBuilder.createInfoResult(e.getMessage());
+    } catch (GemFireSecurityException e) {
+      throw e;
     } catch (Throwable t) {
       SystemFailure.checkFailure();
       getCache().getLogger().info(t);
@@ -308,6 +320,8 @@ public class LuceneIndexCommands implements GfshCommand {
   @CliCommand(value = LuceneCliStrings.LUCENE_DESTROY_INDEX,
       help = LuceneCliStrings.LUCENE_DESTROY_INDEX__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
   public Result destroyIndex(@CliOption(key = LuceneCliStrings.LUCENE__INDEX_NAME,
       help = LuceneCliStrings.LUCENE_DESTROY_INDEX__NAME__HELP) final String indexName,
 
@@ -324,8 +338,6 @@ public class LuceneIndexCommands implements GfshCommand {
           CliStrings.format(LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__INDEX_CANNOT_BE_EMPTY));
     }
 
-    getCache().getSecurityService().authorizeRegionManage(regionPath);
-
     Result result;
     try {
       List<CliFunctionResult> accumulatedResults = new ArrayList<>();
@@ -528,7 +540,7 @@ public class LuceneIndexCommands implements GfshCommand {
     final List<Set<LuceneSearchResults>> functionResults =
         (List<Set<LuceneSearchResults>>) rc.getResult();
 
-    return functionResults.stream().flatMap(set -> set.stream()).sorted()
+    return functionResults.stream().flatMap(Collection::stream).sorted()
         .collect(Collectors.toList());
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexInfo.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexInfo.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexInfo.java
index 41b066e..ad59f0f 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexInfo.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexInfo.java
@@ -14,16 +14,6 @@
  */
 package org.apache.geode.cache.lucene.internal.cli;
 
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import org.apache.geode.cache.lucene.internal.LuceneIndexImpl;
-
-import org.apache.lucene.analysis.Analyzer;
-
 public class LuceneIndexInfo extends LuceneFunctionSerializable {
   private static final long serialVersionUID = 1L;
 

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneCreateIndexFunction.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneCreateIndexFunction.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneCreateIndexFunction.java
index 5e36efa..2d3f8d2 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneCreateIndexFunction.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneCreateIndexFunction.java
@@ -19,6 +19,9 @@ import static org.apache.geode.cache.lucene.internal.LuceneServiceImpl.validateC
 import static org.apache.geode.cache.lucene.internal.LuceneServiceImpl.validateCommandParameters.REGION_PATH;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.execute.FunctionAdapter;
@@ -30,12 +33,14 @@ import org.apache.geode.cache.lucene.internal.cli.LuceneCliStrings;
 import org.apache.geode.cache.lucene.internal.cli.LuceneIndexDetails;
 import org.apache.geode.cache.lucene.internal.cli.LuceneIndexInfo;
 import org.apache.geode.internal.InternalEntity;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.functions.CliFunctionResult;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.configuration.domain.XmlEntity;
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.geode.security.ResourcePermission.Operation;
+import org.apache.geode.security.ResourcePermission.Resource;
+import org.apache.geode.security.ResourcePermission.Target;
 
 
 /**
@@ -88,6 +93,11 @@ public class LuceneCreateIndexFunction extends FunctionAdapter implements Intern
       }
 
       REGION_PATH.validateName(indexInfo.getRegionPath());
+
+      // Every lucene index potentially writes to disk.
+      ((InternalCache) cache).getSecurityService().authorize(Resource.CLUSTER, Operation.WRITE,
+          Target.DISK);
+
       indexFactory.create(indexInfo.getIndexName(), indexInfo.getRegionPath());
 
       // TODO - update cluster configuration by returning a valid XmlEntity

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java
index 423fc59..7cc6709 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java
@@ -20,6 +20,17 @@ import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANA
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+import java.io.Serializable;
+import java.util.Properties;
+
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.lucene.internal.cli.LuceneCliStrings;
 import org.apache.geode.management.cli.Result;
@@ -34,16 +45,6 @@ import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-import java.io.Serializable;
-import java.util.Properties;
-import junitparams.JUnitParamsRunner;
-import junitparams.Parameters;
 
 @Category({DistributedTest.class, SecurityTest.class})
 @RunWith(JUnitParamsRunner.class)
@@ -57,25 +58,26 @@ public class LuceneCommandsSecurityDUnitTest {
 
   private MemberVM locator;
 
-  private MemberVM server;
-
   @Before
   public void before() throws Exception {
-    startLocator();
-    startServer();
-  }
-
-  private void startLocator() throws Exception {
+    // start the locator
     Properties props = new Properties();
     props.setProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName());
     this.locator = this.locatorServer.startLocatorVM(0, props);
+
+    // start the server
+    props = new Properties();
+    props.setProperty("security-username", "clusterManage");
+    props.setProperty("security-password", "clusterManage");
+    this.locatorServer.startServerVM(1, props, this.locator.getPort());
   }
 
-  private void startServer() throws Exception {
-    Properties props = new Properties();
-    props.setProperty("security-username", "clustermanage");
-    props.setProperty("security-password", "clustermanage");
-    this.server = this.locatorServer.startServerVM(1, props, this.locator.getPort());
+  protected UserNameAndExpectedResponse[] getCreateIndexUserNameAndExpectedResponses() {
+    return new UserNameAndExpectedResponse[] {
+        new UserNameAndExpectedResponse("noPermissions", true,
+            "Unauthorized. Reason : noPermissions not authorized for CLUSTER:MANAGE:QUERY"),
+        new UserNameAndExpectedResponse("clusterManageQuery", false,
+            "Successfully created lucene index")};
   }
 
   @Test
@@ -92,6 +94,13 @@ public class LuceneCommandsSecurityDUnitTest {
     verifyResult(user, result);
   }
 
+  protected UserNameAndExpectedResponse[] getSearchIndexUserNameAndExpectedResponses() {
+    return new UserNameAndExpectedResponse[] {
+        new UserNameAndExpectedResponse("noPermissions", true,
+            "Unauthorized. Reason : noPermissions not authorized for DATA:READ:region"),
+        new UserNameAndExpectedResponse("dataRead", false, "No results")};
+  }
+
   @Test
   @Parameters(method = "getSearchIndexUserNameAndExpectedResponses")
   public void verifySearchIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
@@ -109,6 +118,13 @@ public class LuceneCommandsSecurityDUnitTest {
     verifyResult(user, result);
   }
 
+  protected UserNameAndExpectedResponse[] getListIndexesUserNameAndExpectedResponses() {
+    return new UserNameAndExpectedResponse[] {
+        new UserNameAndExpectedResponse("noPermissions", true,
+            "Unauthorized. Reason : noPermissions not authorized for CLUSTER:READ:QUERY"),
+        new UserNameAndExpectedResponse("clusterReadQuery", false, "Index Name")};
+  }
+
   @Test
   @Parameters(method = "getListIndexesUserNameAndExpectedResponses")
   public void verifyListIndexesPermissions(UserNameAndExpectedResponse user) throws Exception {
@@ -126,6 +142,13 @@ public class LuceneCommandsSecurityDUnitTest {
     verifyResult(user, result);
   }
 
+  protected UserNameAndExpectedResponse[] getDescribeIndexUserNameAndExpectedResponses() {
+    return new UserNameAndExpectedResponse[] {
+        new UserNameAndExpectedResponse("noPermissions", true,
+            "Unauthorized. Reason : noPermissions not authorized for CLUSTER:READ:QUERY"),
+        new UserNameAndExpectedResponse("clusterReadQuery", false, "Index Name")};
+  }
+
   @Test
   @Parameters(method = "getDescribeIndexUserNameAndExpectedResponses")
   public void verifyDescribeIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
@@ -143,6 +166,14 @@ public class LuceneCommandsSecurityDUnitTest {
     verifyResult(user, result);
   }
 
+  protected UserNameAndExpectedResponse[] getDestroyIndexUserNameAndExpectedResponses() {
+    return new UserNameAndExpectedResponse[] {
+        new UserNameAndExpectedResponse("noPermissions", true,
+            "Unauthorized. Reason : noPermissions not authorized for CLUSTER:MANAGE:QUERY"),
+        new UserNameAndExpectedResponse("clusterManageQuery", false,
+            "Successfully destroyed lucene index")};
+  }
+
   @Test
   @Parameters(method = "getDestroyIndexUserNameAndExpectedResponses")
   public void verifyDestroyIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
@@ -163,7 +194,7 @@ public class LuceneCommandsSecurityDUnitTest {
   private void createIndexAndRegion() throws Exception {
     // Connect gfsh to locator with permissions necessary to create an index and region
     this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
-        GfshShellConnectionRule.PortType.locator, "datamanage", "datamanage");
+        GfshShellConnectionRule.PortType.locator, "cluster,data", "cluster,data");
 
     // Create lucene index
     this.gfshShell.executeAndVerifyCommand(getCreateIndexCommand());
@@ -186,7 +217,7 @@ public class LuceneCommandsSecurityDUnitTest {
     assertTrue(this.gfshShell.getGfshOutput().contains(user.getExpectedResponse()));
   }
 
-  private String getCreateIndexCommand() throws Exception {
+  private String getCreateIndexCommand() {
     CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
     csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
     csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
@@ -194,7 +225,7 @@ public class LuceneCommandsSecurityDUnitTest {
     return csb.toString();
   }
 
-  private String getCreateRegionCommand() throws Exception {
+  private String getCreateRegionCommand() {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_REGION);
     csb.addOption(CliStrings.CREATE_REGION__REGION, REGION_NAME);
     csb.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT,
@@ -202,7 +233,7 @@ public class LuceneCommandsSecurityDUnitTest {
     return csb.toString();
   }
 
-  private String getSearchIndexCommand() throws Exception {
+  private String getSearchIndexCommand() {
     CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_SEARCH_INDEX);
     csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
     csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
@@ -211,62 +242,25 @@ public class LuceneCommandsSecurityDUnitTest {
     return csb.toString();
   }
 
-  private String getListIndexesCommand() throws Exception {
+  private String getListIndexesCommand() {
     CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_LIST_INDEX);
     return csb.toString();
   }
 
-  private String getDescribeIndexCommand() throws Exception {
+  private String getDescribeIndexCommand() {
     CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESCRIBE_INDEX);
     csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
     csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
     return csb.toString();
   }
 
-  private String getDestroyIndexCommand() throws Exception {
+  private String getDestroyIndexCommand() {
     CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESTROY_INDEX);
     csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
     csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
     return csb.toString();
   }
 
-  protected UserNameAndExpectedResponse[] getCreateIndexUserNameAndExpectedResponses() {
-    return new UserNameAndExpectedResponse[] {
-        new UserNameAndExpectedResponse("nopermissions", true,
-            "Unauthorized. Reason : nopermissions not authorized for DATA:MANAGE:region"),
-        new UserNameAndExpectedResponse("datamanageregion", false,
-            "Successfully created lucene index")};
-  }
-
-  protected UserNameAndExpectedResponse[] getSearchIndexUserNameAndExpectedResponses() {
-    return new UserNameAndExpectedResponse[] {
-        new UserNameAndExpectedResponse("nopermissions", true,
-            "Unauthorized. Reason : nopermissions not authorized for DATA:WRITE"),
-        new UserNameAndExpectedResponse("datawrite", false, "No results")};
-  }
-
-  protected UserNameAndExpectedResponse[] getListIndexesUserNameAndExpectedResponses() {
-    return new UserNameAndExpectedResponse[] {
-        new UserNameAndExpectedResponse("nopermissions", true,
-            "Unauthorized. Reason : nopermissions not authorized for CLUSTER:READ"),
-        new UserNameAndExpectedResponse("clusterread", false, "Index Name")};
-  }
-
-  protected UserNameAndExpectedResponse[] getDescribeIndexUserNameAndExpectedResponses() {
-    return new UserNameAndExpectedResponse[] {
-        new UserNameAndExpectedResponse("nopermissions", true,
-            "Unauthorized. Reason : nopermissions not authorized for CLUSTER:READ"),
-        new UserNameAndExpectedResponse("clusterread", false, "Index Name")};
-  }
-
-  protected UserNameAndExpectedResponse[] getDestroyIndexUserNameAndExpectedResponses() {
-    return new UserNameAndExpectedResponse[] {
-        new UserNameAndExpectedResponse("nopermissions", true,
-            "Unauthorized. Reason : nopermissions not authorized for DATA:MANAGE:region"),
-        new UserNameAndExpectedResponse("datamanageregion", false,
-            "Successfully destroyed lucene index")};
-  }
-
   public static class UserNameAndExpectedResponse implements Serializable {
 
     private final String userName;

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-web/src/test/java/org/apache/geode/management/internal/security/GfshCommandsOverHttpSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/security/GfshCommandsOverHttpSecurityTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/security/GfshCommandsOverHttpSecurityTest.java
index 25068bc..0410e7f 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/security/GfshCommandsOverHttpSecurityTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/security/GfshCommandsOverHttpSecurityTest.java
@@ -15,11 +15,11 @@
 
 package org.apache.geode.management.internal.security;
 
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
-
 import org.apache.geode.test.junit.categories.SecurityTest;
-import org.junit.experimental.categories.Category;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class GfshCommandsOverHttpSecurityTest extends GfshCommandsSecurityTest {


[30/46] geode git commit: Revert: GEODE-2924: fix lucene commands security test

Posted by zh...@apache.org.
Revert: GEODE-2924: fix lucene commands security test


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

Branch: refs/heads/feature/GEM-1483
Commit: 658b20fab920b34ea1c240d26227da48e6644e64
Parents: 8053450
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Sun Jun 25 07:44:09 2017 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Sun Jun 25 07:44:09 2017 -0700

----------------------------------------------------------------------
 .../geode/internal/util/PasswordUtil.java       |  27 +-
 .../lucene/LuceneClientSecurityDUnitTest.java   |  18 +-
 .../lucene/LuceneCommandsSecurityDUnitTest.java | 291 +++++++++++++++++++
 .../lucene/LuceneCommandsSecurityTest.java      | 263 -----------------
 4 files changed, 317 insertions(+), 282 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/658b20fa/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java b/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
index 2495959..5cc3bcd 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
@@ -49,20 +49,23 @@ public class PasswordUtil {
    */
   @Deprecated
   public static String decrypt(String password) {
+    String toDecrypt;
     if (password.startsWith("encrypted(") && password.endsWith(")")) {
-      byte[] decrypted = null;
-      try {
-        String toDecrypt = password.substring(10, password.length() - 1);
-        SecretKeySpec key = new SecretKeySpec(init, "Blowfish");
-        Cipher cipher = Cipher.getInstance("Blowfish");
-        cipher.init(Cipher.DECRYPT_MODE, key);
-        decrypted = cipher.doFinal(hexStringToByteArray(toDecrypt));
-        return new String(decrypted);
-      } catch (Exception e) {
-        e.printStackTrace();
-      }
+      toDecrypt = password.substring(10, password.length() - 1);
+    } else {
+      toDecrypt = password;
     }
-    return password;
+    byte[] decrypted;
+    try {
+      SecretKeySpec key = new SecretKeySpec(init, "Blowfish");
+      Cipher cipher = Cipher.getInstance("Blowfish");
+      cipher.init(Cipher.DECRYPT_MODE, key);
+      decrypted = cipher.doFinal(hexStringToByteArray(toDecrypt));
+      return new String(decrypted);
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+    return toDecrypt;
   }
 
   private static byte[] hexStringToByteArray(String s) {

http://git-wip-us.apache.org/repos/asf/geode/blob/658b20fa/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneClientSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneClientSecurityDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneClientSecurityDUnitTest.java
index 7ab3365..f78e19f 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneClientSecurityDUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneClientSecurityDUnitTest.java
@@ -50,7 +50,7 @@ public class LuceneClientSecurityDUnitTest extends LuceneQueriesAccessorBase {
   @Test
   @Parameters(method = "getSearchIndexUserNameAndExpectedResponses")
   public void verifySearchIndexPermissions(
-      LuceneCommandsSecurityTest.UserNameAndExpectedResponse user) {
+      LuceneCommandsSecurityDUnitTest.UserNameAndExpectedResponse user) {
     // Start server
     int serverPort = dataStore1.invoke(() -> startCacheServer());
 
@@ -58,7 +58,8 @@ public class LuceneClientSecurityDUnitTest extends LuceneQueriesAccessorBase {
     accessor.invoke(() -> startClient(user.getUserName(), serverPort));
 
     // Attempt query
-    accessor.invoke(() -> executeTextSearch(user.getExpectAuthorizationError()));
+    accessor.invoke(
+        () -> executeTextSearch(user.getExpectAuthorizationError(), user.getExpectedResponse()));
   }
 
   private int startCacheServer() throws IOException {
@@ -85,7 +86,8 @@ public class LuceneClientSecurityDUnitTest extends LuceneQueriesAccessorBase {
     clientCache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create(REGION_NAME);
   }
 
-  private void executeTextSearch(boolean expectAuthorizationError) throws LuceneQueryException {
+  private void executeTextSearch(boolean expectAuthorizationError, String expectedResponse)
+      throws LuceneQueryException {
     LuceneService service = LuceneServiceProvider.get(getCache());
     LuceneQuery<Integer, TestObject> query =
         service.createLuceneQueryFactory().create(INDEX_NAME, REGION_NAME, "test", "text");
@@ -95,12 +97,14 @@ public class LuceneClientSecurityDUnitTest extends LuceneQueriesAccessorBase {
     } catch (ServerOperationException e) {
       assertTrue(e.getCause() != null && e.getCause() instanceof NotAuthorizedException);
       assertTrue(expectAuthorizationError);
+      assertTrue(e.getLocalizedMessage().contains(expectedResponse));
     }
   }
 
-  protected LuceneCommandsSecurityTest.UserNameAndExpectedResponse[] getSearchIndexUserNameAndExpectedResponses() {
-    return new LuceneCommandsSecurityTest.UserNameAndExpectedResponse[] {
-        new LuceneCommandsSecurityTest.UserNameAndExpectedResponse("nopermissions", true),
-        new LuceneCommandsSecurityTest.UserNameAndExpectedResponse("datawrite", false)};
+  protected LuceneCommandsSecurityDUnitTest.UserNameAndExpectedResponse[] getSearchIndexUserNameAndExpectedResponses() {
+    return new LuceneCommandsSecurityDUnitTest.UserNameAndExpectedResponse[] {
+        new LuceneCommandsSecurityDUnitTest.UserNameAndExpectedResponse("nopermissions", true,
+            "nopermissions not authorized for DATA:WRITE"),
+        new LuceneCommandsSecurityDUnitTest.UserNameAndExpectedResponse("datawrite", false, null)};
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/658b20fa/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java
new file mode 100644
index 0000000..7cc6709
--- /dev/null
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java
@@ -0,0 +1,291 @@
+/*
+ * 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.cache.lucene;
+
+import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME;
+import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.cache.lucene.internal.cli.LuceneCliStrings;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.CommandResult;
+import org.apache.geode.management.internal.cli.result.ErrorResultData;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
+import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
+import org.apache.geode.security.SimpleTestSecurityManager;
+import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.categories.SecurityTest;
+
+@Category({DistributedTest.class, SecurityTest.class})
+@RunWith(JUnitParamsRunner.class)
+public class LuceneCommandsSecurityDUnitTest {
+
+  @Rule
+  public LocatorServerStartupRule locatorServer = new LocatorServerStartupRule();
+
+  @Rule
+  public GfshShellConnectionRule gfshShell = new GfshShellConnectionRule();
+
+  private MemberVM locator;
+
+  @Before
+  public void before() throws Exception {
+    // start the locator
+    Properties props = new Properties();
+    props.setProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName());
+    this.locator = this.locatorServer.startLocatorVM(0, props);
+
+    // start the server
+    props = new Properties();
+    props.setProperty("security-username", "clusterManage");
+    props.setProperty("security-password", "clusterManage");
+    this.locatorServer.startServerVM(1, props, this.locator.getPort());
+  }
+
+  protected UserNameAndExpectedResponse[] getCreateIndexUserNameAndExpectedResponses() {
+    return new UserNameAndExpectedResponse[] {
+        new UserNameAndExpectedResponse("noPermissions", true,
+            "Unauthorized. Reason : noPermissions not authorized for CLUSTER:MANAGE:QUERY"),
+        new UserNameAndExpectedResponse("clusterManageQuery", false,
+            "Successfully created lucene index")};
+  }
+
+  @Test
+  @Parameters(method = "getCreateIndexUserNameAndExpectedResponses")
+  public void verifyCreateIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
+    // Connect gfsh
+    this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
+        GfshShellConnectionRule.PortType.locator, user.getUserName(), user.getUserName());
+
+    // Attempt to create lucene index
+    CommandResult result = this.gfshShell.executeCommand(getCreateIndexCommand());
+
+    // Verify result
+    verifyResult(user, result);
+  }
+
+  protected UserNameAndExpectedResponse[] getSearchIndexUserNameAndExpectedResponses() {
+    return new UserNameAndExpectedResponse[] {
+        new UserNameAndExpectedResponse("noPermissions", true,
+            "Unauthorized. Reason : noPermissions not authorized for DATA:READ:region"),
+        new UserNameAndExpectedResponse("dataRead", false, "No results")};
+  }
+
+  @Test
+  @Parameters(method = "getSearchIndexUserNameAndExpectedResponses")
+  public void verifySearchIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
+    // Create index and region
+    createIndexAndRegion();
+
+    // Connect gfsh
+    this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
+        GfshShellConnectionRule.PortType.locator, user.getUserName(), user.getUserName());
+
+    // Attempt to search lucene index
+    CommandResult result = this.gfshShell.executeCommand(getSearchIndexCommand());
+
+    // Verify result
+    verifyResult(user, result);
+  }
+
+  protected UserNameAndExpectedResponse[] getListIndexesUserNameAndExpectedResponses() {
+    return new UserNameAndExpectedResponse[] {
+        new UserNameAndExpectedResponse("noPermissions", true,
+            "Unauthorized. Reason : noPermissions not authorized for CLUSTER:READ:QUERY"),
+        new UserNameAndExpectedResponse("clusterReadQuery", false, "Index Name")};
+  }
+
+  @Test
+  @Parameters(method = "getListIndexesUserNameAndExpectedResponses")
+  public void verifyListIndexesPermissions(UserNameAndExpectedResponse user) throws Exception {
+    // Create index and region
+    createIndexAndRegion();
+
+    // Connect gfsh
+    this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
+        GfshShellConnectionRule.PortType.locator, user.getUserName(), user.getUserName());
+
+    // Attempt to search lucene index
+    CommandResult result = this.gfshShell.executeCommand(getListIndexesCommand());
+
+    // Verify result
+    verifyResult(user, result);
+  }
+
+  protected UserNameAndExpectedResponse[] getDescribeIndexUserNameAndExpectedResponses() {
+    return new UserNameAndExpectedResponse[] {
+        new UserNameAndExpectedResponse("noPermissions", true,
+            "Unauthorized. Reason : noPermissions not authorized for CLUSTER:READ:QUERY"),
+        new UserNameAndExpectedResponse("clusterReadQuery", false, "Index Name")};
+  }
+
+  @Test
+  @Parameters(method = "getDescribeIndexUserNameAndExpectedResponses")
+  public void verifyDescribeIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
+    // Create index and region
+    createIndexAndRegion();
+
+    // Connect gfsh
+    this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
+        GfshShellConnectionRule.PortType.locator, user.getUserName(), user.getUserName());
+
+    // Attempt to search lucene index
+    CommandResult result = this.gfshShell.executeCommand(getDescribeIndexCommand());
+
+    // Verify result
+    verifyResult(user, result);
+  }
+
+  protected UserNameAndExpectedResponse[] getDestroyIndexUserNameAndExpectedResponses() {
+    return new UserNameAndExpectedResponse[] {
+        new UserNameAndExpectedResponse("noPermissions", true,
+            "Unauthorized. Reason : noPermissions not authorized for CLUSTER:MANAGE:QUERY"),
+        new UserNameAndExpectedResponse("clusterManageQuery", false,
+            "Successfully destroyed lucene index")};
+  }
+
+  @Test
+  @Parameters(method = "getDestroyIndexUserNameAndExpectedResponses")
+  public void verifyDestroyIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
+    // Create index and region
+    createIndexAndRegion();
+
+    // Connect gfsh
+    this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
+        GfshShellConnectionRule.PortType.locator, user.getUserName(), user.getUserName());
+
+    // Attempt to search lucene index
+    CommandResult result = this.gfshShell.executeCommand(getDestroyIndexCommand());
+
+    // Verify result
+    verifyResult(user, result);
+  }
+
+  private void createIndexAndRegion() throws Exception {
+    // Connect gfsh to locator with permissions necessary to create an index and region
+    this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
+        GfshShellConnectionRule.PortType.locator, "cluster,data", "cluster,data");
+
+    // Create lucene index
+    this.gfshShell.executeAndVerifyCommand(getCreateIndexCommand());
+
+    // Create region
+    this.gfshShell.executeAndVerifyCommand(getCreateRegionCommand());
+
+    // Disconnect gfsh
+    this.gfshShell.disconnect();
+  }
+
+  private void verifyResult(UserNameAndExpectedResponse user, CommandResult result) {
+    if (user.getExpectAuthorizationError()) {
+      assertTrue(result.getResultData() instanceof ErrorResultData);
+      assertEquals(ResultBuilder.ERRORCODE_UNAUTHORIZED,
+          ((ErrorResultData) result.getResultData()).getErrorCode());
+    } else {
+      assertEquals(Result.Status.OK, result.getStatus());
+    }
+    assertTrue(this.gfshShell.getGfshOutput().contains(user.getExpectedResponse()));
+  }
+
+  private String getCreateIndexCommand() {
+    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
+    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
+    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
+    csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1");
+    return csb.toString();
+  }
+
+  private String getCreateRegionCommand() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_REGION);
+    csb.addOption(CliStrings.CREATE_REGION__REGION, REGION_NAME);
+    csb.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT,
+        RegionShortcut.PARTITION_REDUNDANT.name());
+    return csb.toString();
+  }
+
+  private String getSearchIndexCommand() {
+    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_SEARCH_INDEX);
+    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
+    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
+    csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING, "field1:value1");
+    csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field1");
+    return csb.toString();
+  }
+
+  private String getListIndexesCommand() {
+    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_LIST_INDEX);
+    return csb.toString();
+  }
+
+  private String getDescribeIndexCommand() {
+    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESCRIBE_INDEX);
+    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
+    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
+    return csb.toString();
+  }
+
+  private String getDestroyIndexCommand() {
+    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESTROY_INDEX);
+    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
+    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
+    return csb.toString();
+  }
+
+  public static class UserNameAndExpectedResponse implements Serializable {
+
+    private final String userName;
+
+    private final boolean expectAuthorizationError;
+
+    private final String expectedResponse;
+
+    public UserNameAndExpectedResponse(String userName, boolean expectAuthorizationError,
+        String expectedResponse) {
+      this.userName = userName;
+      this.expectAuthorizationError = expectAuthorizationError;
+      this.expectedResponse = expectedResponse;
+    }
+
+    public String getUserName() {
+      return this.userName;
+    }
+
+    public boolean getExpectAuthorizationError() {
+      return this.expectAuthorizationError;
+    }
+
+    public String getExpectedResponse() {
+      return this.expectedResponse;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/658b20fa/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityTest.java
deleted file mode 100644
index c195611..0000000
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityTest.java
+++ /dev/null
@@ -1,263 +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.cache.lucene;
-
-import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME;
-import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.Serializable;
-
-import junitparams.JUnitParamsRunner;
-import junitparams.Parameters;
-import org.junit.After;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.cache.lucene.internal.cli.LuceneCliStrings;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.management.internal.cli.result.ErrorResultData;
-import org.apache.geode.management.internal.cli.result.ResultBuilder;
-import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
-import org.apache.geode.security.SimpleTestSecurityManager;
-import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.ServerStarterRule;
-import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.apache.geode.test.junit.categories.SecurityTest;
-
-@Category({IntegrationTest.class, SecurityTest.class})
-@RunWith(JUnitParamsRunner.class)
-public class LuceneCommandsSecurityTest {
-
-  @ClassRule
-  public static ServerStarterRule server = new ServerStarterRule()
-      .withSecurityManager(SimpleTestSecurityManager.class).withJMXManager().withAutoStart();
-
-  @ClassRule
-  public static GfshShellConnectionRule gfshShell = new GfshShellConnectionRule();
-
-  @After
-  public void after() throws Exception {
-    gfshShell.disconnect();
-  }
-
-
-  protected UserNameAndExpectedResponse[] getCreateIndexUserNameAndExpectedResponses() {
-    return new UserNameAndExpectedResponse[] {
-        new UserNameAndExpectedResponse("noPermissions", true),
-        new UserNameAndExpectedResponse("clusterManageQuery,clusterWriteDisk", false)};
-  }
-
-  @Test
-  @Parameters(method = "getCreateIndexUserNameAndExpectedResponses")
-  public void verifyCreateIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
-    // Connect gfsh
-    this.gfshShell.secureConnectAndVerify(this.server.getJmxPort(),
-        GfshShellConnectionRule.PortType.jmxManger, user.getUserName(), user.getUserName());
-
-    // Attempt to create lucene index
-    CommandResult result = this.gfshShell.executeCommand(getCreateIndexCommand());
-
-    // Verify result
-    verifyResult(user, result);
-  }
-
-  protected UserNameAndExpectedResponse[] getSearchIndexUserNameAndExpectedResponses() {
-    return new UserNameAndExpectedResponse[] {
-        new UserNameAndExpectedResponse("noPermissions", true),
-        new UserNameAndExpectedResponse("dataRead", false)};
-  }
-
-  @Test
-  @Parameters(method = "getSearchIndexUserNameAndExpectedResponses")
-  public void verifySearchIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
-    // Create index and region
-    // createIndexAndRegion();
-
-    // Connect gfsh
-    this.gfshShell.secureConnectAndVerify(this.server.getJmxPort(),
-        GfshShellConnectionRule.PortType.jmxManger, user.getUserName(), user.getUserName());
-
-    // Attempt to search lucene index
-    CommandResult result = this.gfshShell.executeCommand(getSearchIndexCommand());
-
-    // Verify result
-    verifyResult(user, result);
-  }
-
-  protected UserNameAndExpectedResponse[] getListIndexesUserNameAndExpectedResponses() {
-    return new UserNameAndExpectedResponse[] {
-        new UserNameAndExpectedResponse("noPermissions", true),
-        new UserNameAndExpectedResponse("clusterReadQuery", false)};
-  }
-
-  @Test
-  @Parameters(method = "getListIndexesUserNameAndExpectedResponses")
-  public void verifyListIndexesPermissions(UserNameAndExpectedResponse user) throws Exception {
-    // Create index and region
-    // createIndexAndRegion();
-
-    // Connect gfsh
-    this.gfshShell.secureConnectAndVerify(this.server.getJmxPort(),
-        GfshShellConnectionRule.PortType.jmxManger, user.getUserName(), user.getUserName());
-
-    // Attempt to search lucene index
-    CommandResult result = this.gfshShell.executeCommand(getListIndexesCommand());
-
-    // Verify result
-    verifyResult(user, result);
-  }
-
-  protected UserNameAndExpectedResponse[] getDescribeIndexUserNameAndExpectedResponses() {
-    return new UserNameAndExpectedResponse[] {
-        new UserNameAndExpectedResponse("noPermissions", true),
-        new UserNameAndExpectedResponse("clusterReadQuery", false)};
-  }
-
-  @Test
-  @Parameters(method = "getDescribeIndexUserNameAndExpectedResponses")
-  public void verifyDescribeIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
-    // Create index and region
-    // createIndexAndRegion();
-
-    // Connect gfsh
-    this.gfshShell.secureConnectAndVerify(this.server.getJmxPort(),
-        GfshShellConnectionRule.PortType.jmxManger, user.getUserName(), user.getUserName());
-
-    // Attempt to search lucene index
-    CommandResult result = this.gfshShell.executeCommand(getDescribeIndexCommand());
-
-    // Verify result
-    verifyResult(user, result);
-  }
-
-  protected UserNameAndExpectedResponse[] getDestroyIndexUserNameAndExpectedResponses() {
-    return new UserNameAndExpectedResponse[] {
-        new UserNameAndExpectedResponse("noPermissions", true),
-        new UserNameAndExpectedResponse("clusterManageQuery", false)};
-  }
-
-  @Test
-  @Parameters(method = "getDestroyIndexUserNameAndExpectedResponses")
-  public void verifyDestroyIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
-    // Create index and region
-    // createIndexAndRegion();
-
-    // Connect gfsh
-    this.gfshShell.secureConnectAndVerify(this.server.getJmxPort(),
-        GfshShellConnectionRule.PortType.jmxManger, user.getUserName(), user.getUserName());
-
-    // Attempt to search lucene index
-    CommandResult result = this.gfshShell.executeCommand(getDestroyIndexCommand());
-
-    // Verify result
-    verifyResult(user, result);
-  }
-
-  private void createIndexAndRegion() throws Exception {
-    // Connect gfsh to locator with permissions necessary to create an index and region
-    this.gfshShell.secureConnectAndVerify(this.server.getJmxPort(),
-        GfshShellConnectionRule.PortType.jmxManger, "cluster,data", "cluster,data");
-
-    // Create lucene index
-    this.gfshShell.executeAndVerifyCommand(getCreateIndexCommand());
-
-    // Create region
-    this.gfshShell.executeAndVerifyCommand(getCreateRegionCommand());
-
-    // Disconnect gfsh
-    this.gfshShell.disconnect();
-  }
-
-  private void verifyResult(UserNameAndExpectedResponse user, CommandResult result) {
-    if (user.getExpectAuthorizationError()) {
-      assertTrue(result.getResultData() instanceof ErrorResultData);
-      assertEquals(ResultBuilder.ERRORCODE_UNAUTHORIZED,
-          ((ErrorResultData) result.getResultData()).getErrorCode());
-    } else {
-      assertEquals(Result.Status.OK, result.getStatus());
-    }
-  }
-
-  private String getCreateIndexCommand() {
-    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
-    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
-    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
-    csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1");
-    return csb.toString();
-  }
-
-  private String getCreateRegionCommand() {
-    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_REGION);
-    csb.addOption(CliStrings.CREATE_REGION__REGION, REGION_NAME);
-    csb.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT,
-        RegionShortcut.PARTITION_REDUNDANT.name());
-    return csb.toString();
-  }
-
-  private String getSearchIndexCommand() {
-    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_SEARCH_INDEX);
-    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
-    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
-    csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING, "field1:value1");
-    csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field1");
-    return csb.toString();
-  }
-
-  private String getListIndexesCommand() {
-    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_LIST_INDEX);
-    return csb.toString();
-  }
-
-  private String getDescribeIndexCommand() {
-    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESCRIBE_INDEX);
-    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
-    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
-    return csb.toString();
-  }
-
-  private String getDestroyIndexCommand() {
-    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESTROY_INDEX);
-    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
-    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
-    return csb.toString();
-  }
-
-  public static class UserNameAndExpectedResponse implements Serializable {
-
-    private final String userName;
-
-    private final boolean expectAuthorizationError;
-
-    public UserNameAndExpectedResponse(String userName, boolean expectAuthorizationError) {
-      this.userName = userName;
-      this.expectAuthorizationError = expectAuthorizationError;
-    }
-
-    public String getUserName() {
-      return this.userName;
-    }
-
-    public boolean getExpectAuthorizationError() {
-      return this.expectAuthorizationError;
-    }
-  }
-}


[13/46] geode git commit: GEODE-3056: fix the message for invalid partition-resolver

Posted by zh...@apache.org.
GEODE-3056: fix the message for invalid partition-resolver


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

Branch: refs/heads/feature/GEM-1483
Commit: d8a11d1e4a4ccc78ddc3f86db172edf0dddf7215
Parents: d8160d6
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Mon Jun 19 09:53:39 2017 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Mon Jun 19 17:09:30 2017 -0700

----------------------------------------------------------------------
 .../CreateAlterDestroyRegionCommands.java       | 13 ++--
 .../CreateAlterDestroyRegionCommandsTest.java   | 65 ++++++++++++++++++++
 2 files changed, 73 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/d8a11d1e/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
index bf22854..b762396 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
@@ -612,14 +612,17 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
     }
   }
 
-  private void validateRegionFunctionArgs(InternalCache cache,
-      RegionFunctionArgs regionFunctionArgs) {
+  DistributedSystemMXBean getDSMBean(InternalCache cache) {
+    ManagementService managementService = ManagementService.getExistingManagementService(cache);
+    return managementService.getDistributedSystemMXBean();
+  }
+
+  void validateRegionFunctionArgs(InternalCache cache, RegionFunctionArgs regionFunctionArgs) {
     if (regionFunctionArgs.getRegionPath() == null) {
       throw new IllegalArgumentException(CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_REGION_PATH);
     }
 
-    ManagementService managementService = ManagementService.getExistingManagementService(cache);
-    DistributedSystemMXBean dsMBean = managementService.getDistributedSystemMXBean();
+    DistributedSystemMXBean dsMBean = getDSMBean(cache);
 
     String useAttributesFrom = regionFunctionArgs.getUseAttributesFrom();
     if (useAttributesFrom != null && !useAttributesFrom.isEmpty()
@@ -840,7 +843,7 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
         } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
           throw new IllegalArgumentException(
               CliStrings.format(CliStrings.CREATE_REGION__MSG__INVALID_PARTITION_RESOLVER,
-                  new Object[] {regionFunctionArgs.getCompressor()}),
+                  new Object[] {regionFunctionArgs.getPartitionResolver()}),
               e);
         }
       }

http://git-wip-us.apache.org/repos/asf/geode/blob/d8a11d1e/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommandsTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommandsTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommandsTest.java
new file mode 100644
index 0000000..155b1ad
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommandsTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.mockito.ArgumentCaptor;
+
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.management.DistributedSystemMXBean;
+import org.apache.geode.management.internal.cli.functions.RegionFunctionArgs;
+import org.apache.geode.test.dunit.rules.GfshParserRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+
+@Category(IntegrationTest.class)
+public class CreateAlterDestroyRegionCommandsTest {
+
+  @Rule
+  public GfshParserRule parser = new GfshParserRule();
+
+  @Test
+  public void testCreateRegionWithInvalidPartitionResolver() throws Exception {
+    InternalCache cache = mock(InternalCache.class);
+    DistributedSystemMXBean dsMBean = mock(DistributedSystemMXBean.class);
+    CreateAlterDestroyRegionCommands spy =
+        parser.spyCommand("create region --name=region3 --type=PARTITION --partition-resolver=Foo");
+    doReturn(cache).when(spy).getCache();
+    doReturn(dsMBean).when(spy).getDSMBean(cache);
+
+    parser.executeLastCommandWithInstance(spy);
+
+    ArgumentCaptor<RegionFunctionArgs> argsCaptor =
+        ArgumentCaptor.forClass(RegionFunctionArgs.class);
+
+    verify(spy).validateRegionFunctionArgs(any(), argsCaptor.capture());
+
+    RegionFunctionArgs args = argsCaptor.getValue();
+    assertThat(args.getPartitionResolver()).isEqualTo("Foo");
+
+    assertThatThrownBy(() -> spy.validateRegionFunctionArgs(cache, args))
+        .hasMessageContaining("Foo is an invalid Partition Resolver");
+  }
+}


[25/46] geode git commit: GEODE-2919: Provide finer grained security

Posted by zh...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RegionCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RegionCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RegionCommands.java
index 68dbbf0..3222666 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RegionCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/RegionCommands.java
@@ -14,6 +14,17 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.execute.FunctionInvocationTargetException;
 import org.apache.geode.cache.execute.ResultCollector;
@@ -31,7 +42,6 @@ import org.apache.geode.management.internal.cli.domain.RegionInformation;
 import org.apache.geode.management.internal.cli.functions.GetRegionDescriptionFunction;
 import org.apache.geode.management.internal.cli.functions.GetRegionsFunction;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.result.CommandResultException;
 import org.apache.geode.management.internal.cli.result.CompositeResultData;
 import org.apache.geode.management.internal.cli.result.CompositeResultData.SectionResultData;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
@@ -40,17 +50,6 @@ import org.apache.geode.management.internal.cli.util.RegionAttributesNames;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
 
 /**
  * Class containing implementation of commands based on region:
@@ -67,8 +66,8 @@ public class RegionCommands implements GfshCommand {
       new GetRegionDescriptionFunction();
 
   @CliCommand(value = {CliStrings.LIST_REGION}, help = CliStrings.LIST_REGION__HELP)
-  @CliMetaData(shellOnly = false, relatedTopic = CliStrings.TOPIC_GEODE_REGION)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.READ)
+  @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_REGION)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   public Result listRegion(
       @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
           optionContext = ConverterHint.MEMBERGROUP,
@@ -78,8 +77,8 @@ public class RegionCommands implements GfshCommand {
           help = CliStrings.LIST_REGION__MEMBER__HELP) String[] memberNameOrId) {
     Result result = null;
     try {
-      Set<RegionInformation> regionInfoSet = new LinkedHashSet<RegionInformation>();
-      ResultCollector<?, ?> rc = null;
+      Set<RegionInformation> regionInfoSet = new LinkedHashSet<>();
+      ResultCollector<?, ?> rc;
 
       Set<DistributedMember> targetMembers = CliUtil.findMembers(group, memberNameOrId);
 
@@ -93,11 +92,8 @@ public class RegionCommands implements GfshCommand {
       ArrayList<?> resultList = (ArrayList<?>) rc.getResult();
 
       if (resultList != null) {
-        Iterator<?> iters = resultList.iterator();
-
-        while (iters.hasNext()) {
-          Object resultObj = iters.next();
 
+        for (Object resultObj : resultList) {
           if (resultObj != null) {
             if (resultObj instanceof Object[]) {
               Object[] resultObjectArray = (Object[]) resultObj;
@@ -110,15 +106,13 @@ public class RegionCommands implements GfshCommand {
           }
         }
 
-        Set<String> regionNames = new TreeSet<String>();
+        Set<String> regionNames = new TreeSet<>();
 
         for (RegionInformation regionInfo : regionInfoSet) {
           regionNames.add(regionInfo.getName());
           Set<String> subRegionNames = regionInfo.getSubRegionNames();
 
-          for (String subRegionName : subRegionNames) {
-            regionNames.add(subRegionName);
-          }
+          regionNames.addAll(subRegionNames);
         }
 
         for (String regionName : regionNames) {
@@ -143,14 +137,13 @@ public class RegionCommands implements GfshCommand {
   }
 
   @CliCommand(value = {CliStrings.DESCRIBE_REGION}, help = CliStrings.DESCRIBE_REGION__HELP)
-  @CliMetaData(shellOnly = false,
-      relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_CONFIG})
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_CONFIG})
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   public Result describeRegion(
       @CliOption(key = CliStrings.DESCRIBE_REGION__NAME, optionContext = ConverterHint.REGION_PATH,
           help = CliStrings.DESCRIBE_REGION__NAME__HELP, mandatory = true) String regionName) {
 
-    Result result = null;
+    Result result;
     try {
 
       if (regionName == null || regionName.isEmpty()) {
@@ -170,7 +163,7 @@ public class RegionCommands implements GfshCommand {
       // The returned result could be a region description with per member and /or single local
       // region
       Object[] results = resultList.toArray();
-      List<RegionDescription> regionDescriptionList = new ArrayList<RegionDescription>();
+      List<RegionDescription> regionDescriptionList = new ArrayList<>();
 
       for (int i = 0; i < results.length; i++) {
 
@@ -204,11 +197,8 @@ public class RegionCommands implements GfshCommand {
       }
 
       CompositeResultData crd = ResultBuilder.createCompositeResultData();
-      Iterator<RegionDescription> iters = regionDescriptionList.iterator();
-
-      while (iters.hasNext()) {
-        RegionDescription regionDescription = iters.next();
 
+      for (RegionDescription regionDescription : regionDescriptionList) {
         // No point in displaying the scope for PR's
         if (regionDescription.isPartition()) {
           regionDescription.getCndRegionAttributes().remove(RegionAttributesNames.SCOPE);
@@ -228,7 +218,7 @@ public class RegionCommands implements GfshCommand {
             regionDescription.getDataPolicy().toString().toLowerCase().replace('_', ' ');
         regionSection.addData("Data Policy", dataPolicy);
 
-        String memberType = "";
+        String memberType;
 
         if (regionDescription.isAccessor()) {
           memberType = CliStrings.DESCRIBE_REGION__ACCESSOR__MEMBER;
@@ -265,8 +255,6 @@ public class RegionCommands implements GfshCommand {
         Set<String> members = regDescPerMemberMap.keySet();
 
         TabularResultData table = regionSection.addSection().addTable();
-        // table.setHeader(CliStrings.format(CliStrings.DESCRIBE_REGION__NONDEFAULT__PERMEMBERATTRIBUTES__HEADER,
-        // memberType));
 
         boolean setHeader = false;
         for (String member : members) {
@@ -291,9 +279,9 @@ public class RegionCommands implements GfshCommand {
 
           if (!(ndRa.isEmpty() && ndEa.isEmpty() && ndPa.isEmpty()) || fpaList != null) {
             setHeader = true;
-            boolean memberNameAdded = false;
+            boolean memberNameAdded;
             memberNameAdded = writeAttributesToTable(table,
-                CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__REGION, ndRa, member, memberNameAdded);
+                CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__REGION, ndRa, member, false);
             memberNameAdded =
                 writeAttributesToTable(table, CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__EVICTION,
                     ndEa, member, memberNameAdded);
@@ -302,12 +290,10 @@ public class RegionCommands implements GfshCommand {
                 memberNameAdded);
 
             writeFixedPartitionAttributesToTable(table, "", fpaList, member, memberNameAdded);
-            // Fix for #46767
-            // writeAttributeToTable(table, "", "", "", "");
           }
         }
 
-        if (setHeader == true) {
+        if (setHeader) {
           table.setHeader(CliStrings.format(
               CliStrings.DESCRIBE_REGION__NONDEFAULT__PERMEMBERATTRIBUTES__HEADER, memberType));
         }
@@ -332,10 +318,7 @@ public class RegionCommands implements GfshCommand {
       boolean isTypeAdded = false;
       final String blank = "";
 
-      Iterator<String> iters = attributes.iterator();
-
-      while (iters.hasNext()) {
-        String attributeName = iters.next();
+      for (String attributeName : attributes) {
         String attributeValue = attributesMap.get(attributeName);
         String type, memName;
 
@@ -403,10 +386,7 @@ public class RegionCommands implements GfshCommand {
       boolean isTypeAdded = false;
       final String blank = "";
 
-      Iterator<String> iters = attributes.iterator();
-
-      while (iters.hasNext()) {
-        String attributeName = iters.next();
+      for (String attributeName : attributes) {
         String attributeValue = attributesMap.get(attributeName);
         String type, memName;
 

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/WanCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/WanCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/WanCommands.java
index a6745fd..c6fb709 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/WanCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/WanCommands.java
@@ -14,6 +14,26 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.management.ObjectName;
+
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.cache.InternalCache;
@@ -44,37 +64,20 @@ import org.apache.geode.management.internal.configuration.domain.XmlEntity;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-import javax.management.ObjectName;
+import org.apache.geode.security.ResourcePermission.Target;
 
 public class WanCommands implements GfshCommand {
 
   @CliCommand(value = CliStrings.CREATE_GATEWAYSENDER, help = CliStrings.CREATE_GATEWAYSENDER__HELP)
   @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.GATEWAY)
   public Result createGatewaySender(@CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
       optionContext = ConverterHint.MEMBERGROUP,
       help = CliStrings.CREATE_GATEWAYSENDER__GROUP__HELP) String[] onGroups,
 
       @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
           optionContext = ConverterHint.MEMBERIDNAME,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.CREATE_GATEWAYSENDER__MEMBER__HELP) String[] onMember,
 
       @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__ID, mandatory = true,
@@ -131,7 +134,7 @@ public class WanCommands implements GfshCommand {
       @CliOption(key = CliStrings.CREATE_GATEWAYSENDER__GATEWAYTRANSPORTFILTER,
           help = CliStrings.CREATE_GATEWAYSENDER__GATEWAYTRANSPORTFILTER__HELP) String[] gatewayTransportFilter) {
 
-    Result result = null;
+    Result result;
 
     AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
     try {
@@ -182,7 +185,8 @@ public class WanCommands implements GfshCommand {
 
   @CliCommand(value = CliStrings.START_GATEWAYSENDER, help = CliStrings.START_GATEWAYSENDER__HELP)
   @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.GATEWAY)
   public Result startGatewaySender(@CliOption(key = CliStrings.START_GATEWAYSENDER__ID,
       mandatory = true, optionContext = ConverterHint.GATEWAY_SENDER_ID,
       help = CliStrings.START_GATEWAYSENDER__ID__HELP) String senderId,
@@ -195,7 +199,7 @@ public class WanCommands implements GfshCommand {
           optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.START_GATEWAYSENDER__MEMBER__HELP) String[] onMember) {
 
-    Result result = null;
+    Result result;
     final String id = senderId.trim();
 
     try {
@@ -222,45 +226,41 @@ public class WanCommands implements GfshCommand {
         }
       });
 
-      List<Callable<List>> callables = new ArrayList<Callable<List>>();
+      List<Callable<List>> callables = new ArrayList<>();
 
       for (final DistributedMember member : dsMembers) {
 
-        callables.add(new Callable<List>() {
-
-          public List call() throws Exception {
+        callables.add(() -> {
 
-            GatewaySenderMXBean bean = null;
-            ArrayList<String> statusList = new ArrayList<String>();
-            if (cache.getDistributedSystem().getDistributedMember().getId()
-                .equals(member.getId())) {
-              bean = service.getLocalGatewaySenderMXBean(id);
-            } else {
-              ObjectName objectName = service.getGatewaySenderMBeanName(member, id);
-              bean = service.getMBeanProxy(objectName, GatewaySenderMXBean.class);
-            }
-            if (bean != null) {
-              if (bean.isRunning()) {
-                statusList.add(member.getId());
-                statusList.add(CliStrings.GATEWAY_ERROR);
-                statusList.add(
-                    CliStrings.format(CliStrings.GATEWAY_SENDER_0_IS_ALREADY_STARTED_ON_MEMBER_1,
-                        id, member.getId()));
-              } else {
-                bean.start();
-                statusList.add(member.getId());
-                statusList.add(CliStrings.GATEWAY_OK);
-                statusList.add(CliStrings.format(CliStrings.GATEWAY_SENDER_0_IS_STARTED_ON_MEMBER_1,
-                    id, member.getId()));
-              }
-            } else {
+          GatewaySenderMXBean bean;
+          ArrayList<String> statusList = new ArrayList<>();
+          if (cache.getDistributedSystem().getDistributedMember().getId().equals(member.getId())) {
+            bean = service.getLocalGatewaySenderMXBean(id);
+          } else {
+            ObjectName objectName = service.getGatewaySenderMBeanName(member, id);
+            bean = service.getMBeanProxy(objectName, GatewaySenderMXBean.class);
+          }
+          if (bean != null) {
+            if (bean.isRunning()) {
               statusList.add(member.getId());
               statusList.add(CliStrings.GATEWAY_ERROR);
               statusList.add(CliStrings.format(
-                  CliStrings.GATEWAY_SENDER_0_IS_NOT_AVAILABLE_ON_MEMBER_1, id, member.getId()));
+                  CliStrings.GATEWAY_SENDER_0_IS_ALREADY_STARTED_ON_MEMBER_1, id, member.getId()));
+            } else {
+              bean.start();
+              statusList.add(member.getId());
+              statusList.add(CliStrings.GATEWAY_OK);
+              statusList.add(CliStrings.format(CliStrings.GATEWAY_SENDER_0_IS_STARTED_ON_MEMBER_1,
+                  id, member.getId()));
             }
-            return statusList;
+          } else {
+            statusList.add(member.getId());
+            statusList.add(CliStrings.GATEWAY_ERROR);
+            statusList.add(CliStrings.format(
+                CliStrings.GATEWAY_SENDER_0_IS_NOT_AVAILABLE_ON_MEMBER_1, id, member.getId()));
           }
+          return statusList;
+
         });
       }
 
@@ -276,21 +276,15 @@ public class WanCommands implements GfshCommand {
 
       for (Future<List> future : futures) {
         DistributedMember member = memberIterator.next();
-        List<String> memberStatus = null;
+        List<String> memberStatus;
         try {
           memberStatus = future.get();
           accumulateStartResult(resultData, memberStatus.get(0), memberStatus.get(1),
               memberStatus.get(2));
-        } catch (InterruptedException ite) {
+        } catch (InterruptedException | ExecutionException ite) {
           accumulateStartResult(resultData, member.getId(), CliStrings.GATEWAY_ERROR,
               CliStrings.format(CliStrings.GATEWAY_SENDER_0_COULD_NOT_BE_STARTED_ON_MEMBER_DUE_TO_1,
                   id, ite.getMessage()));
-          continue;
-        } catch (ExecutionException ee) {
-          accumulateStartResult(resultData, member.getId(), CliStrings.GATEWAY_ERROR,
-              CliStrings.format(CliStrings.GATEWAY_SENDER_0_COULD_NOT_BE_STARTED_ON_MEMBER_DUE_TO_1,
-                  id, ee.getMessage()));
-          continue;
         }
       }
       execService.shutdown();
@@ -305,7 +299,8 @@ public class WanCommands implements GfshCommand {
 
   @CliCommand(value = CliStrings.PAUSE_GATEWAYSENDER, help = CliStrings.PAUSE_GATEWAYSENDER__HELP)
   @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.GATEWAY)
   public Result pauseGatewaySender(@CliOption(key = CliStrings.PAUSE_GATEWAYSENDER__ID,
       mandatory = true, optionContext = ConverterHint.GATEWAY_SENDER_ID,
       help = CliStrings.PAUSE_GATEWAYSENDER__ID__HELP) String senderId,
@@ -318,7 +313,7 @@ public class WanCommands implements GfshCommand {
           optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.PAUSE_GATEWAYSENDER__MEMBER__HELP) String[] onMember) {
 
-    Result result = null;
+    Result result;
     if (senderId != null) {
       senderId = senderId.trim();
     }
@@ -328,7 +323,7 @@ public class WanCommands implements GfshCommand {
       SystemManagementService service =
           (SystemManagementService) ManagementService.getExistingManagementService(cache);
 
-      GatewaySenderMXBean bean = null;
+      GatewaySenderMXBean bean;
 
       TabularResultData resultData = ResultBuilder.createTabularResultData();
 
@@ -378,7 +373,8 @@ public class WanCommands implements GfshCommand {
 
   @CliCommand(value = CliStrings.RESUME_GATEWAYSENDER, help = CliStrings.RESUME_GATEWAYSENDER__HELP)
   @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.GATEWAY)
   public Result resumeGatewaySender(@CliOption(key = CliStrings.RESUME_GATEWAYSENDER__ID,
       mandatory = true, optionContext = ConverterHint.GATEWAY_SENDER_ID,
       help = CliStrings.RESUME_GATEWAYSENDER__ID__HELP) String senderId,
@@ -390,7 +386,7 @@ public class WanCommands implements GfshCommand {
           optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.RESUME_GATEWAYSENDER__MEMBER__HELP) String[] onMember) {
 
-    Result result = null;
+    Result result;
     if (senderId != null) {
       senderId = senderId.trim();
     }
@@ -400,7 +396,7 @@ public class WanCommands implements GfshCommand {
       SystemManagementService service =
           (SystemManagementService) ManagementService.getExistingManagementService(cache);
 
-      GatewaySenderMXBean bean = null;
+      GatewaySenderMXBean bean;
 
       TabularResultData resultData = ResultBuilder.createTabularResultData();
 
@@ -450,7 +446,8 @@ public class WanCommands implements GfshCommand {
 
   @CliCommand(value = CliStrings.STOP_GATEWAYSENDER, help = CliStrings.STOP_GATEWAYSENDER__HELP)
   @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.GATEWAY)
   public Result stopGatewaySender(@CliOption(key = CliStrings.STOP_GATEWAYSENDER__ID,
       mandatory = true, optionContext = ConverterHint.GATEWAY_SENDER_ID,
       help = CliStrings.STOP_GATEWAYSENDER__ID__HELP) String senderId,
@@ -463,7 +460,7 @@ public class WanCommands implements GfshCommand {
           optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.STOP_GATEWAYSENDER__MEMBER__HELP) String[] onMember) {
 
-    Result result = null;
+    Result result;
     if (senderId != null)
       senderId = senderId.trim();
 
@@ -472,7 +469,7 @@ public class WanCommands implements GfshCommand {
       SystemManagementService service =
           (SystemManagementService) ManagementService.getExistingManagementService(cache);
 
-      GatewaySenderMXBean bean = null;
+      GatewaySenderMXBean bean;
 
       TabularResultData resultData = ResultBuilder.createTabularResultData();
 
@@ -518,14 +515,14 @@ public class WanCommands implements GfshCommand {
   @CliCommand(value = CliStrings.CREATE_GATEWAYRECEIVER,
       help = CliStrings.CREATE_GATEWAYRECEIVER__HELP)
   @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.GATEWAY)
   public Result createGatewayReceiver(@CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
       optionContext = ConverterHint.MEMBERGROUP,
       help = CliStrings.CREATE_GATEWAYRECEIVER__GROUP__HELP) String[] onGroups,
 
       @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
           optionContext = ConverterHint.MEMBERIDNAME,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.CREATE_GATEWAYRECEIVER__MEMBER__HELP) String[] onMember,
 
       @CliOption(key = CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART,
@@ -549,7 +546,7 @@ public class WanCommands implements GfshCommand {
       @CliOption(key = CliStrings.CREATE_GATEWAYRECEIVER__GATEWAYTRANSPORTFILTER,
           help = CliStrings.CREATE_GATEWAYRECEIVER__GATEWAYTRANSPORTFILTER__HELP) String[] gatewayTransportFilters) {
 
-    Result result = null;
+    Result result;
 
     AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
     try {
@@ -601,12 +598,13 @@ public class WanCommands implements GfshCommand {
   @CliCommand(value = CliStrings.LOAD_BALANCE_GATEWAYSENDER,
       help = CliStrings.LOAD_BALANCE_GATEWAYSENDER__HELP)
   @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.GATEWAY)
   public Result loadBalanceGatewaySender(@CliOption(key = CliStrings.LOAD_BALANCE_GATEWAYSENDER__ID,
       mandatory = true, optionContext = ConverterHint.GATEWAY_SENDER_ID,
       help = CliStrings.LOAD_BALANCE_GATEWAYSENDER__ID__HELP) String senderId) {
 
-    Result result = null;
+    Result result;
     if (senderId != null) {
       senderId = senderId.trim();
     }
@@ -623,7 +621,7 @@ public class WanCommands implements GfshCommand {
       } else {
         boolean gatewaySenderExists = false;
         for (DistributedMember member : dsMembers) {
-          GatewaySenderMXBean bean = null;
+          GatewaySenderMXBean bean;
           if (cache.getDistributedSystem().getDistributedMember().getId().equals(member.getId())) {
             bean = service.getLocalGatewaySenderMXBean(senderId);
           } else {
@@ -660,7 +658,8 @@ public class WanCommands implements GfshCommand {
   @CliCommand(value = CliStrings.START_GATEWAYRECEIVER,
       help = CliStrings.START_GATEWAYRECEIVER__HELP)
   @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.GATEWAY)
   public Result startGatewayReceiver(@CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
       optionContext = ConverterHint.MEMBERGROUP,
       help = CliStrings.START_GATEWAYRECEIVER__GROUP__HELP) String[] onGroup,
@@ -668,14 +667,14 @@ public class WanCommands implements GfshCommand {
       @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
           optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.START_GATEWAYRECEIVER__MEMBER__HELP) String[] onMember) {
-    Result result = null;
+    Result result;
 
     try {
       InternalCache cache = getCache();
       SystemManagementService service =
           (SystemManagementService) ManagementService.getExistingManagementService(cache);
 
-      GatewayReceiverMXBean receieverBean = null;
+      GatewayReceiverMXBean receiverBean;
 
       TabularResultData resultData = ResultBuilder.createTabularResultData();
 
@@ -689,15 +688,15 @@ public class WanCommands implements GfshCommand {
         ObjectName gatewayReceiverObjectName = MBeanJMXAdapter.getGatewayReceiverMBeanName(member);
 
         if (gatewayReceiverObjectName != null) {
-          receieverBean =
+          receiverBean =
               service.getMBeanProxy(gatewayReceiverObjectName, GatewayReceiverMXBean.class);
-          if (receieverBean != null) {
-            if (receieverBean.isRunning()) {
+          if (receiverBean != null) {
+            if (receiverBean.isRunning()) {
               accumulateStartResult(resultData, member.getId(), CliStrings.GATEWAY_ERROR,
                   CliStrings.format(CliStrings.GATEWAY_RECEIVER_IS_ALREADY_STARTED_ON_MEMBER_0,
                       new Object[] {member.getId()}));
             } else {
-              receieverBean.start();
+              receiverBean.start();
               accumulateStartResult(resultData, member.getId(), CliStrings.GATEWAY_OK,
                   CliStrings.format(CliStrings.GATEWAY_RECEIVER_IS_STARTED_ON_MEMBER_0,
                       new Object[] {member.getId()}));
@@ -725,7 +724,8 @@ public class WanCommands implements GfshCommand {
 
   @CliCommand(value = CliStrings.STOP_GATEWAYRECEIVER, help = CliStrings.STOP_GATEWAYRECEIVER__HELP)
   @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.GATEWAY)
   public Result stopGatewayReceiver(
 
       @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
@@ -736,14 +736,14 @@ public class WanCommands implements GfshCommand {
           optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.STOP_GATEWAYRECEIVER__MEMBER__HELP) String[] onMember) {
 
-    Result result = null;
+    Result result;
 
     try {
       InternalCache cache = getCache();
       SystemManagementService service =
           (SystemManagementService) ManagementService.getExistingManagementService(cache);
 
-      GatewayReceiverMXBean receieverBean = null;
+      GatewayReceiverMXBean receiverBean;
 
       TabularResultData resultData = ResultBuilder.createTabularResultData();
 
@@ -757,11 +757,11 @@ public class WanCommands implements GfshCommand {
         ObjectName gatewayReceiverObjectName = MBeanJMXAdapter.getGatewayReceiverMBeanName(member);
 
         if (gatewayReceiverObjectName != null) {
-          receieverBean =
+          receiverBean =
               service.getMBeanProxy(gatewayReceiverObjectName, GatewayReceiverMXBean.class);
-          if (receieverBean != null) {
-            if (receieverBean.isRunning()) {
-              receieverBean.stop();
+          if (receiverBean != null) {
+            if (receiverBean.isRunning()) {
+              receiverBean.stop();
               accumulateStartResult(resultData, member.getId(), CliStrings.GATEWAY_OK,
                   CliStrings.format(CliStrings.GATEWAY_RECEIVER_IS_STOPPED_ON_MEMBER_0,
                       new Object[] {member.getId()}));
@@ -802,7 +802,7 @@ public class WanCommands implements GfshCommand {
           optionContext = ConverterHint.MEMBERGROUP,
           help = CliStrings.LIST_GATEWAY__GROUP__HELP) String[] onGroup) {
 
-    Result result = null;
+    Result result;
     InternalCache cache = getCache();
     try {
       SystemManagementService service =
@@ -814,10 +814,8 @@ public class WanCommands implements GfshCommand {
         return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
       }
 
-      Map<String, Map<String, GatewaySenderMXBean>> gatewaySenderBeans =
-          new TreeMap<String, Map<String, GatewaySenderMXBean>>();
-      Map<String, GatewayReceiverMXBean> gatewayReceiverBeans =
-          new TreeMap<String, GatewayReceiverMXBean>();
+      Map<String, Map<String, GatewaySenderMXBean>> gatewaySenderBeans = new TreeMap<>();
+      Map<String, GatewayReceiverMXBean> gatewayReceiverBeans = new TreeMap<>();
 
       DistributedSystemMXBean dsMXBean = service.getDistributedSystemMXBean();
       for (DistributedMember member : dsMembers) {
@@ -837,8 +835,7 @@ public class WanCommands implements GfshCommand {
                     gatewaySenderBeans.get(senderBean.getSenderId());
                 memberToBeanMap.put(member.getId(), senderBean);
               } else {
-                Map<String, GatewaySenderMXBean> memberToBeanMap =
-                    new TreeMap<String, GatewaySenderMXBean>();
+                Map<String, GatewaySenderMXBean> memberToBeanMap = new TreeMap<>();
                 memberToBeanMap.put(member.getId(), senderBean);
                 gatewaySenderBeans.put(senderBean.getSenderId(), memberToBeanMap);
               }
@@ -848,11 +845,11 @@ public class WanCommands implements GfshCommand {
         // gateway receivers : a member can have only one gateway receiver
         ObjectName gatewayReceiverObjectName = MBeanJMXAdapter.getGatewayReceiverMBeanName(member);
         if (gatewayReceiverObjectName != null) {
-          GatewayReceiverMXBean receieverBean = null;
-          receieverBean =
+          GatewayReceiverMXBean receiverBean;
+          receiverBean =
               service.getMBeanProxy(gatewayReceiverObjectName, GatewayReceiverMXBean.class);
-          if (receieverBean != null) {
-            gatewayReceiverBeans.put(member.getId(), receieverBean);
+          if (receiverBean != null) {
+            gatewayReceiverBeans.put(member.getId(), receiverBean);
           }
         }
       }
@@ -886,7 +883,7 @@ public class WanCommands implements GfshCommand {
           optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.STATUS_GATEWAYSENDER__MEMBER__HELP) String[] onMember) {
 
-    Result result = null;
+    Result result;
     if (senderId != null)
       senderId = senderId.trim();
     try {
@@ -894,7 +891,7 @@ public class WanCommands implements GfshCommand {
       SystemManagementService service =
           (SystemManagementService) ManagementService.getExistingManagementService(cache);
 
-      GatewaySenderMXBean bean = null;
+      GatewaySenderMXBean bean;
 
       CompositeResultData crd = ResultBuilder.createCompositeResultData();
       TabularResultData availableSenderData =
@@ -944,7 +941,7 @@ public class WanCommands implements GfshCommand {
           optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.STATUS_GATEWAYRECEIVER__MEMBER__HELP) String[] onMember) {
 
-    Result result = null;
+    Result result;
 
     try {
       InternalCache cache = getCache();
@@ -969,10 +966,10 @@ public class WanCommands implements GfshCommand {
       for (DistributedMember member : dsMembers) {
         ObjectName gatewayReceiverObjectName = MBeanJMXAdapter.getGatewayReceiverMBeanName(member);
         if (gatewayReceiverObjectName != null) {
-          GatewayReceiverMXBean receieverBean =
+          GatewayReceiverMXBean receiverBean =
               service.getMBeanProxy(gatewayReceiverObjectName, GatewayReceiverMXBean.class);
-          if (receieverBean != null) {
-            buildReceiverStatus(member.getId(), receieverBean, availableReceiverData);
+          if (receiverBean != null) {
+            buildReceiverStatus(member.getId(), receiverBean, availableReceiverData);
             continue;
           }
         }
@@ -989,19 +986,19 @@ public class WanCommands implements GfshCommand {
   @CliCommand(value = CliStrings.DESTROY_GATEWAYSENDER,
       help = CliStrings.DESTROY_GATEWAYSENDER__HELP)
   @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.GATEWAY)
   public Result destroyGatewaySender(
       @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
           optionContext = ConverterHint.MEMBERGROUP,
           help = CliStrings.DESTROY_GATEWAYSENDER__GROUP__HELP) String[] onGroups,
       @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
           optionContext = ConverterHint.MEMBERIDNAME,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.DESTROY_GATEWAYSENDER__MEMBER__HELP) String[] onMember,
       @CliOption(key = CliStrings.DESTROY_GATEWAYSENDER__ID, mandatory = true,
           optionContext = ConverterHint.GATEWAY_SENDER_ID,
           help = CliStrings.DESTROY_GATEWAYSENDER__ID__HELP) String id) {
-    Result result = null;
+    Result result;
     try {
       GatewaySenderDestroyFunctionArgs gatewaySenderDestroyFunctionArgs =
           new GatewaySenderDestroyFunctionArgs(id);
@@ -1128,7 +1125,7 @@ public class WanCommands implements GfshCommand {
 
 
   private Result handleCommandResultException(CommandResultException crex) {
-    Result result = null;
+    Result result;
     if (crex.getResult() != null) {
       result = crex.getResult();
     } else {

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StartPulseCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StartPulseCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StartPulseCommand.java
index b5c6148..fbf32d8 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StartPulseCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StartPulseCommand.java
@@ -16,6 +16,15 @@ package org.apache.geode.management.internal.cli.commands.lifecycle;
 
 import static org.apache.geode.internal.Assert.assertState;
 
+import java.awt.Desktop;
+import java.io.IOException;
+import java.net.URI;
+
+import javax.management.ObjectName;
+
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.SystemFailure;
 import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.management.cli.CliMetaData;
@@ -25,13 +34,6 @@ import org.apache.geode.management.internal.cli.commands.GfshCommand;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
 import org.apache.geode.management.internal.cli.shell.OperationInvoker;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.awt.Desktop;
-import java.io.IOException;
-import java.net.URI;
-import javax.management.ObjectName;
 
 public class StartPulseCommand implements GfshCommand {
 
@@ -85,7 +87,7 @@ public class StartPulseCommand implements GfshCommand {
 
   private void browse(URI uri) throws IOException {
     assertState(Desktop.isDesktopSupported(),
-        String.format(CliStrings.DESKSTOP_APP_RUN_ERROR_MESSAGE, System.getProperty("os.name")));
+        String.format(CliStrings.DESKTOP_APP_RUN_ERROR_MESSAGE, System.getProperty("os.name")));
     Desktop.getDesktop().browse(uri);
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ContinuousQueryFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ContinuousQueryFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ContinuousQueryFunction.java
new file mode 100644
index 0000000..1f06a41
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ContinuousQueryFunction.java
@@ -0,0 +1,148 @@
+/*
+ * 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.functions;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Iterator;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.internal.InternalEntity;
+import org.apache.geode.internal.cache.CacheServerImpl;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.cache.tier.sockets.AcceptorImpl;
+import org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier;
+import org.apache.geode.internal.cache.tier.sockets.CacheClientProxy;
+import org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID;
+import org.apache.geode.internal.cache.tier.sockets.ServerConnection;
+
+/**
+ * @since GemFire 8.0
+ */
+public class ContinuousQueryFunction implements Function, InternalEntity {
+  private static final long serialVersionUID = 1L;
+
+  public static final String ID = ContinuousQueryFunction.class.getName();
+
+  private InternalCache getCache() {
+    return (InternalCache) CacheFactory.getAnyInstance();
+  }
+
+  @Override
+  public void execute(FunctionContext context) {
+    try {
+      String clientID = (String) context.getArguments();
+      InternalCache cache = getCache();
+      if (cache.getCacheServers().size() > 0) {
+        CacheServerImpl server = (CacheServerImpl) cache.getCacheServers().iterator().next();
+        if (server != null) {
+          AcceptorImpl acceptorImpl = server.getAcceptor();
+          if (acceptorImpl != null) {
+            CacheClientNotifier cacheClientNotifier = acceptorImpl.getCacheClientNotifier();
+            if (cacheClientNotifier != null) {
+              Collection<CacheClientProxy> cacheClientProxySet =
+                  cacheClientNotifier.getClientProxies();
+              ClientInfo clientInfo = null;
+              boolean foundClientinCCP = false;
+              Iterator<CacheClientProxy> it = cacheClientProxySet.iterator();
+              while (it.hasNext()) {
+
+                CacheClientProxy ccp = it.next();
+                if (ccp != null) {
+                  String clientIdFromProxy = ccp.getProxyID().getDSMembership();
+                  if (clientIdFromProxy != null && clientIdFromProxy.equals(clientID)) {
+                    foundClientinCCP = true;
+                    String durableId = ccp.getProxyID().getDurableId();
+                    boolean isPrimary = ccp.isPrimary();
+                    clientInfo = new ClientInfo(
+                        (durableId != null && durableId.length() > 0 ? "Yes" : "No"),
+                        (isPrimary == true
+                            ? cache.getDistributedSystem().getDistributedMember().getId() : ""),
+                        (isPrimary == false
+                            ? cache.getDistributedSystem().getDistributedMember().getId() : ""));
+                    break;
+
+                  }
+                }
+              }
+
+              // try getting from server connections
+              if (foundClientinCCP == false) {
+                ServerConnection[] serverConnections = acceptorImpl.getAllServerConnectionList();
+
+                for (ServerConnection conn : serverConnections) {
+                  ClientProxyMembershipID cliIdFrmProxy = conn.getProxyID();
+
+                  if (clientID.equals(cliIdFrmProxy.getDSMembership())) {
+                    String durableId = cliIdFrmProxy.getDurableId();
+                    clientInfo =
+                        new ClientInfo((durableId != null && durableId.length() > 0 ? "Yes" : "No"),
+                            "N.A.", "N.A.");
+                  }
+
+                }
+              }
+              context.getResultSender().lastResult(clientInfo);
+            }
+          }
+        }
+      }
+    } catch (Exception e) {
+      context.getResultSender()
+          .lastResult("Exception in ContinuousQueryFunction =" + e.getMessage());
+    }
+    context.getResultSender().lastResult(null);
+  }
+
+  @Override
+  public String getId() {
+    return ContinuousQueryFunction.ID;
+  }
+
+  @Override
+  public boolean hasResult() {
+    return true;
+  }
+
+  @Override
+  public boolean optimizeForWrite() {
+    return false;
+  }
+
+  @Override
+  public boolean isHA() {
+    return false;
+  }
+
+  public class ClientInfo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    public String isDurable;
+    public String primaryServer;
+    public String secondaryServer;
+
+    public ClientInfo(String IsClientDurable, String primaryServerId, String secondaryServerId) {
+      isDurable = IsClientDurable;
+      primaryServer = primaryServerId;
+      secondaryServer = secondaryServerId;
+    }
+
+    @Override
+    public String toString() {
+      return "ClientInfo [isDurable=" + isDurable + ", primaryServer=" + primaryServer
+          + ", secondaryServer=" + secondaryServer + "]";
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ContunuousQueryFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ContunuousQueryFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ContunuousQueryFunction.java
deleted file mode 100644
index 47890e1..0000000
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ContunuousQueryFunction.java
+++ /dev/null
@@ -1,150 +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.functions;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Iterator;
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.cache.execute.Function;
-import org.apache.geode.cache.execute.FunctionContext;
-import org.apache.geode.internal.InternalEntity;
-import org.apache.geode.internal.cache.CacheServerImpl;
-import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.internal.cache.tier.sockets.AcceptorImpl;
-import org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier;
-import org.apache.geode.internal.cache.tier.sockets.CacheClientProxy;
-import org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID;
-import org.apache.geode.internal.cache.tier.sockets.ServerConnection;
-
-/**
- * TODO: rename ContunuousQueryFunction
- * 
- * @since GemFire 8.0
- */
-public class ContunuousQueryFunction implements Function, InternalEntity {
-  private static final long serialVersionUID = 1L;
-
-  public static final String ID = ContunuousQueryFunction.class.getName();
-
-  private InternalCache getCache() {
-    return (InternalCache) CacheFactory.getAnyInstance();
-  }
-
-  @Override
-  public void execute(FunctionContext context) {
-    try {
-      String clientID = (String) context.getArguments();
-      InternalCache cache = getCache();
-      if (cache.getCacheServers().size() > 0) {
-        CacheServerImpl server = (CacheServerImpl) cache.getCacheServers().iterator().next();
-        if (server != null) {
-          AcceptorImpl acceptorImpl = server.getAcceptor();
-          if (acceptorImpl != null) {
-            CacheClientNotifier cacheClientNotifier = acceptorImpl.getCacheClientNotifier();
-            if (cacheClientNotifier != null) {
-              Collection<CacheClientProxy> cacheClientProxySet =
-                  cacheClientNotifier.getClientProxies();
-              ClientInfo clientInfo = null;
-              boolean foundClientinCCP = false;
-              Iterator<CacheClientProxy> it = cacheClientProxySet.iterator();
-              while (it.hasNext()) {
-
-                CacheClientProxy ccp = it.next();
-                if (ccp != null) {
-                  String clientIdFromProxy = ccp.getProxyID().getDSMembership();
-                  if (clientIdFromProxy != null && clientIdFromProxy.equals(clientID)) {
-                    foundClientinCCP = true;
-                    String durableId = ccp.getProxyID().getDurableId();
-                    boolean isPrimary = ccp.isPrimary();
-                    clientInfo = new ClientInfo(
-                        (durableId != null && durableId.length() > 0 ? "Yes" : "No"),
-                        (isPrimary == true
-                            ? cache.getDistributedSystem().getDistributedMember().getId() : ""),
-                        (isPrimary == false
-                            ? cache.getDistributedSystem().getDistributedMember().getId() : ""));
-                    break;
-
-                  }
-                }
-              }
-
-              // try getting from server connections
-              if (foundClientinCCP == false) {
-                ServerConnection[] serverConnections = acceptorImpl.getAllServerConnectionList();
-
-                for (ServerConnection conn : serverConnections) {
-                  ClientProxyMembershipID cliIdFrmProxy = conn.getProxyID();
-
-                  if (clientID.equals(cliIdFrmProxy.getDSMembership())) {
-                    String durableId = cliIdFrmProxy.getDurableId();
-                    clientInfo =
-                        new ClientInfo((durableId != null && durableId.length() > 0 ? "Yes" : "No"),
-                            "N.A.", "N.A.");
-                  }
-
-                }
-              }
-              context.getResultSender().lastResult(clientInfo);
-            }
-          }
-        }
-      }
-    } catch (Exception e) {
-      context.getResultSender()
-          .lastResult("Exception in ContunuousQueryFunction =" + e.getMessage());
-    }
-    context.getResultSender().lastResult(null);
-  }
-
-  @Override
-  public String getId() {
-    return ContunuousQueryFunction.ID;
-  }
-
-  @Override
-  public boolean hasResult() {
-    return true;
-  }
-
-  @Override
-  public boolean optimizeForWrite() {
-    return false;
-  }
-
-  @Override
-  public boolean isHA() {
-    return false;
-  }
-
-  public class ClientInfo implements Serializable {
-    private static final long serialVersionUID = 1L;
-    public String isDurable;
-    public String primaryServer;
-    public String secondaryServer;
-
-    public ClientInfo(String IsClientDurable, String primaryServerId, String secondaryServerId) {
-      isDurable = IsClientDurable;
-      primaryServer = primaryServerId;
-      secondaryServer = secondaryServerId;
-    }
-
-    @Override
-    public String toString() {
-      return "ClientInfo [isDurable=" + isDurable + ", primaryServer=" + primaryServer
-          + ", secondaryServer=" + secondaryServer + "]";
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionFunctionArgs.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionFunctionArgs.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionFunctionArgs.java
index 573b82e..3af79eb 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionFunctionArgs.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionFunctionArgs.java
@@ -13,12 +13,6 @@
  * the License.
  */
 
-/**
- * Used to carry arguments between gfsh region command implementations and the functions that do the
- * work for those commands.
- * 
- * @since GemFire 7.0
- */
 package org.apache.geode.management.internal.cli.functions;
 
 import java.io.Serializable;
@@ -35,6 +29,12 @@ import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 
+/**
+ * Used to carry arguments between gfsh region command implementations and the functions that do the
+ * work for those commands.
+ *
+ * @since GemFire 7.0
+ */
 public class RegionFunctionArgs implements Serializable {
   private static final long serialVersionUID = -5158224572470173267L;
 
@@ -122,7 +122,7 @@ public class RegionFunctionArgs implements Serializable {
       this.enableSubscriptionConflation = enableSubscriptionConflation;
     }
     if (cacheListeners != null) {
-      this.cacheListeners = new LinkedHashSet<String>();
+      this.cacheListeners = new LinkedHashSet<>();
       this.cacheListeners.addAll(Arrays.asList(cacheListeners));
     } else {
       this.cacheListeners = null;
@@ -130,13 +130,13 @@ public class RegionFunctionArgs implements Serializable {
     this.cacheLoader = cacheLoader;
     this.cacheWriter = cacheWriter;
     if (asyncEventQueueIds != null) {
-      this.asyncEventQueueIds = new LinkedHashSet<String>();
+      this.asyncEventQueueIds = new LinkedHashSet<>();
       this.asyncEventQueueIds.addAll(Arrays.asList(asyncEventQueueIds));
     } else {
       this.asyncEventQueueIds = null;
     }
     if (gatewaySenderIds != null) {
-      this.gatewaySenderIds = new LinkedHashSet<String>();
+      this.gatewaySenderIds = new LinkedHashSet<>();
       this.gatewaySenderIds.addAll(Arrays.asList(gatewaySenderIds));
     } else {
       this.gatewaySenderIds = null;
@@ -527,7 +527,7 @@ public class RegionFunctionArgs implements Serializable {
     }
 
     public ExpirationAttributes convertToExpirationAttributes() {
-      ExpirationAttributes expirationAttr = null;
+      ExpirationAttributes expirationAttr;
       if (action != null) {
         expirationAttr = new ExpirationAttributes(time, action);
       } else {
@@ -590,8 +590,8 @@ public class RegionFunctionArgs implements Serializable {
       }
     }
 
-    public static enum ExpirationFor {
-      REGION_IDLE, REGION_TTL, ENTRY_IDLE, ENTRY_TTL;
+    public enum ExpirationFor {
+      REGION_IDLE, REGION_TTL, ENTRY_IDLE, ENTRY_TTL
     }
   }
 
@@ -615,7 +615,7 @@ public class RegionFunctionArgs implements Serializable {
     private String partitionResolver;
 
     private boolean hasPartitionAttributes;
-    private final Set<String> userSpecifiedPartitionAttributes = new HashSet<String>();
+    private final Set<String> userSpecifiedPartitionAttributes = new HashSet<>();
 
     public PartitionArgs(String prColocatedWith, Integer prLocalMaxMemory, Long prRecoveryDelay,
         Integer prRedundantCopies, Long prStartupRecoveryDelay, Long prTotalMaxMemory,

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/UserFunctionExecution.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/UserFunctionExecution.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/UserFunctionExecution.java
index 630c2bc..1f9a607 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/UserFunctionExecution.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/UserFunctionExecution.java
@@ -17,7 +17,6 @@ package org.apache.geode.management.internal.cli.functions;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import java.util.concurrent.CancellationException;
 
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
@@ -25,7 +24,6 @@ import org.apache.geode.cache.Region;
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionContext;
-import org.apache.geode.cache.execute.FunctionException;
 import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.distributed.DistributedMember;
@@ -61,7 +59,7 @@ public class UserFunctionExecution implements Function, InternalEntity {
           if (argumentsString != null && argumentsString.length() > 0) {
             functionArgs = argumentsString.split(",");
           }
-          Set<String> filters = new HashSet<String>();
+          Set<String> filters = new HashSet<>();
           ResultCollector resultCollectorInstance = null;
           if (resultCollectorName != null && resultCollectorName.length() > 0) {
             resultCollectorInstance = (ResultCollector) ClassPathLoader.getLatest()
@@ -94,29 +92,29 @@ public class UserFunctionExecution implements Function, InternalEntity {
               if (functionArgs != null && functionArgs.length > 0) {
                 execution = execution.setArguments(functionArgs);
               }
-              if (filters != null && filters.size() > 0) {
+              if (filters.size() > 0) {
                 execution = execution.withFilter(filters);
               }
 
               List<Object> results = (List<Object>) execution.execute(function).getResult();
 
-              StringBuilder resultMessege = new StringBuilder();
+              StringBuilder resultMessage = new StringBuilder();
               if (results != null) {
                 for (Object resultObj : results) {
                   if (resultObj != null) {
                     if (resultObj instanceof String) {
-                      resultMessege.append(((String) resultObj));
-                      resultMessege.append(GfshParser.LINE_SEPARATOR);
+                      resultMessage.append(((String) resultObj));
+                      resultMessage.append(GfshParser.LINE_SEPARATOR);
                     } else if (resultObj instanceof Exception) {
-                      resultMessege.append(((IllegalArgumentException) resultObj).getMessage());
+                      resultMessage.append(((IllegalArgumentException) resultObj).getMessage());
                     } else {
-                      resultMessege.append(resultObj);
-                      resultMessege.append(GfshParser.LINE_SEPARATOR);
+                      resultMessage.append(resultObj);
+                      resultMessage.append(GfshParser.LINE_SEPARATOR);
                     }
                   }
                 }
               }
-              context.getResultSender().lastResult(resultMessege);
+              context.getResultSender().lastResult(resultMessage);
             } else {
               context.getResultSender()
                   .lastResult(CliStrings.format(
@@ -126,27 +124,7 @@ public class UserFunctionExecution implements Function, InternalEntity {
             }
           }
 
-        } catch (ClassNotFoundException e) {
-          context.getResultSender()
-              .lastResult(CliStrings.format(
-                  CliStrings.EXECUTE_FUNCTION__MSG__RESULT_COLLECTOR_0_NOT_FOUND_ERROR_1,
-                  resultCollectorName, e.getMessage()));
-        } catch (FunctionException e) {
-          context.getResultSender()
-              .lastResult(CliStrings.format(
-                  CliStrings.EXECUTE_FUNCTION__MSG__ERROR_IN_EXECUTING_ON_MEMBER_1_DETAILS_2,
-                  functionId, member.getId(), e.getMessage()));
-        } catch (CancellationException e) {
-          context.getResultSender()
-              .lastResult(CliStrings.format(
-                  CliStrings.EXECUTE_FUNCTION__MSG__ERROR_IN_EXECUTING_ON_MEMBER_1_DETAILS_2,
-                  functionId, member.getId(), e.getMessage()));
-        } catch (InstantiationException e) {
-          context.getResultSender()
-              .lastResult(CliStrings.format(
-                  CliStrings.EXECUTE_FUNCTION__MSG__RESULT_COLLECTOR_0_NOT_FOUND_ERROR_1,
-                  resultCollectorName, e.getMessage()));
-        } catch (IllegalAccessException e) {
+        } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
           context.getResultSender()
               .lastResult(CliStrings.format(
                   CliStrings.EXECUTE_FUNCTION__MSG__RESULT_COLLECTOR_0_NOT_FOUND_ERROR_1,

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
index 0f74edd..3d4d53f 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
@@ -140,7 +140,7 @@ public class CliStrings {
   public static final String TOPIC_GFSH__DESC = "The Geode Shell";
   public static final String TOPIC_SHARED_CONFIGURATION = "Cluster Configuration";
   public static final String TOPIC_SHARED_CONFIGURATION_HELP =
-      "Configuration for cluster and various groups. It consists of cache.xml, geode properties and deployed jars.\nChanges due to gfshs command are persisted to the locator hosting the cluster configuration service.";
+      "Configuration for cluster and various groups. It consists of cache.xml, geode properties and deployed jars.\nChanges due to gfsh command are persisted to the locator hosting the cluster configuration service.";
   public static final String TOPIC_LOGS = "Logs";
   public static final String TOPIC_LOGS__DESC = "Generate log contents as per the need";
   public static final String TOPIC_CLIENT = "Client";
@@ -150,7 +150,7 @@ public class CliStrings {
    * ********* String Constants other than command name, options & help ******
    * *************************************************************************/
 
-  public static final String DESKSTOP_APP_RUN_ERROR_MESSAGE =
+  public static final String DESKTOP_APP_RUN_ERROR_MESSAGE =
       "Running desktop applications is not supported on %1$s.";
   public static final String GEODE_HOME_NOT_FOUND_ERROR_MESSAGE =
       "The GEODE environment variable was not defined.  Please set the GEODE environment variable to the directory where GEODE is installed.";
@@ -203,7 +203,7 @@ public class CliStrings {
   public static final String NO_CLIENT_FOUND = "No client found on this server";
   public static final String NO_CLIENT_FOUND_WITH_CLIENT_ID =
       "No client found with client-id : {0}";
-  public static final String ACTION_SUCCCEEDED_ON_MEMBER = "{0} on following members.";
+  public static final String ACTION_SUCCEEDED_ON_MEMBER = "{0} on following members.";
   public static final String OCCURRED_ON_MEMBERS = "Occurred on members";
   public static final String SHARED_CONFIGURATION_NOT_STARTED =
       "Cluster configuration service is enabled but has not started yet.";
@@ -216,8 +216,8 @@ public class CliStrings {
   public static final String GFSHPARSER__MSG__REQUIRED_ARGUMENT_0 = "Required Argument: \"{0}\"";
   public static final String GFSHPARSER__MSG__VALUE_REQUIRED_FOR_OPTION_0 =
       "Value is required for parameter \"{0}\"";
-  public static final String GFSHPARSER__MSG__AMBIGIOUS_COMMAND_0_FOR_ASSISTANCE_USE_1_OR_HINT_HELP =
-      "Ambigious command \"{0}\" (for assistance press \"{1}\" or type \"hint\" or \"help <command name>\" & then hit ENTER)";
+  public static final String GFSHPARSER__MSG__AMBIGUOUS_COMMAND_0_FOR_ASSISTANCE_USE_1_OR_HINT_HELP =
+      "Ambiguous command \"{0}\" (for assistance press \"{1}\" or type \"hint\" or \"help <command name>\" & then hit ENTER)";
   public static final String GFSHPARSER__MSG__COMMAND_ARGUMENT_0_IS_REQUIRED_USE_HELP =
       "Command parameter \"{0}\" is required. Use \"help <command name>\" for assistance.";
   public static final String GFSHPARSER__MSG__COMMAND_OPTION_0_IS_REQUIRED_USE_HELP =
@@ -583,7 +583,7 @@ public class CliStrings {
       "The gfsecurity.properties file for configuring gfsh to connect to the Locator/Manager. The file's path can be absolute or relative to gfsh directory.";
   public static final String CONNECT__USE_SSL = "use-ssl";
   public static final String CONNECT__USE_SSL__HELP =
-      "Whether to use SSL for communication with Locator and/or JMX Manager. If set to \"true\", will also read \"gfsecurity.properties\". SSL Options take precedence over proeprties file. If none are specified, defaults will be used. The default value for this options is \"false\".";
+      "Whether to use SSL for communication with Locator and/or JMX Manager. If set to \"true\", will also read \"gfsecurity.properties\". SSL Options take precedence over properties file. If none are specified, defaults will be used. The default value for this options is \"false\".";
   public static final String CONNECT__MSG__CONNECTING_TO_MANAGER_AT_0 =
       "Connecting to Manager at {0} ..";
   public static final String CONNECT__MSG__CONNECTING_TO_MANAGER_HTTP_SERVICE_AT_0 =
@@ -1326,7 +1326,7 @@ public class CliStrings {
   public static final String EXECUTE_FUNCTION__MSG__ERROR_IN_EXECUTING_0_ON_MEMBER_1_ON_REGION_2_DETAILS_3 =
       "While executing function : {0} on member : {1} one region : {2} error occurred : {3}";
   public static final String EXECUTE_FUNCTION__MSG__MEMBER_SHOULD_NOT_HAVE_FILTER_FOR_EXECUTION =
-      "Filters for executing on \"member\"/\"mebers of group\" is not supported.";
+      "Filters for executing on \"member\"/\"members of group\" is not supported.";
 
   /* exit command */
   public static final String EXIT = "exit";
@@ -1366,7 +1366,7 @@ public class CliStrings {
   public static final String EXPORT_DATA__MEMBER__NOT__FOUND = "Member {0} not found";
   public static final String EXPORT_DATA__REGION__NOT__FOUND = "Region {0} not found";
   public static final String EXPORT_DATA__SUCCESS__MESSAGE =
-      "Data succesfully exported from region : {0} to file : {1} on host : {2}";
+      "Data successfully exported from region : {0} to file : {1} on host : {2}";
 
   /* export logs command */
   public static final String EXPORT_LOGS = "export logs";
@@ -1607,7 +1607,7 @@ public class CliStrings {
   public static final String DESCRIBE_CLIENT_COLUMN_DURABLE = "Is Durable";
   public static final String DESCRIBE_CLIENT_MIN_CONN = "Minimum Connections";
   public static final String DESCRIBE_CLIENT_MAX_CONN = "Maximum Connections";
-  public static final String DESCRIBE_CLIENT_REDUDANCY = "Redudancy";
+  public static final String DESCRIBE_CLIENT_REDUNDANCY = "Redundancy";
   public static final String DESCRIBE_CLIENT_CQs = "Num of CQs";
 
 
@@ -1722,7 +1722,7 @@ public class CliStrings {
       "Group of members on which to run the netstat command.";
   public static final String NETSTAT__FILE = "file";
   public static final String NETSTAT__FILE__HELP =
-      "Text file to which output from the netstat command will be written. A \".txt\" extention will be added if it's not already a part of the specified name.";
+      "Text file to which output from the netstat command will be written. A \".txt\" extension will be added if it's not already a part of the specified name.";
   public static final String NETSTAT__WITHLSOF = "with-lsof";
   public static final String NETSTAT__WITHLSOF__HELP =
       "Whether lsof (list open files) command output should also be displayed. Not applicable for \"Microsoft Windows(TM)\" hosts.";
@@ -1848,9 +1848,9 @@ public class CliStrings {
   public static final String REBALANCE__MSG__NO_REBALANCING_REGIONS_ON_DS =
       "Distributed system has no regions that can be rebalanced";
   public static final String REBALANCE__MSG__EXCEPTION_IN_REBALANCE_FOR_MEMBER_0_Exception =
-      "Excpetion occurred while rebalancing on member : {0} . Exception is ";
+      "Exception occurred while rebalancing on member : {0} . Exception is ";
   public static final String REBALANCE__MSG__EXCEPTION_IN_REBALANCE_FOR_MEMBER_0_Exception_1 =
-      "Excpetion occurred while rebalancing on member : {0} . Exception is : {1}";
+      "Exception occurred while rebalancing on member : {0} . Exception is : {1}";
   public static final String REBALANCE__MSG__ERROR_IN_RETRIEVING_MBEAN =
       "Could not retrieve MBean for region : {0}";
   public static final String REBALANCE__MSG__NO_EXECUTION_FOR_REGION_0_ON_MEMBERS_1 =
@@ -1864,7 +1864,7 @@ public class CliStrings {
       "Rebalance will continue in background";
   public static final String REBALANCE__MSG__REGION_NOT_ASSOCIATED_WITH_MORE_THAN_ONE_MEMBER =
       "No regions associated with more than 1 members";
-  public static final String REBALANCE__MSG__EXCEPTION_OCCRED_WHILE_REBALANCING_0 =
+  public static final String REBALANCE__MSG__EXCEPTION_OCCURRED_WHILE_REBALANCING_0 =
       "Exception occurred while rebelancing. Reason : {0}";
 
   /* remove command */
@@ -1954,7 +1954,7 @@ public class CliStrings {
       + "3. APP_LAST_EXIT_STATUS            Numeric value for last command exit status. One of: 0 (success), 1 (error), 2 (crash) (read only)\n"
       + "4. APP_COLLECTION_LIMIT            Number of items in the embedded collection of a result to be iterated. Valid values are: 1-100.\n"
       + "5. APP_QUERY_RESULTS_DISPLAY_MODE  How command results should be shown. Valid values are: table and catalog.\n"
-      + "6. APP_QUIET_EXECUTION.            Whether commands should be excuted in quiet mode. Valid values are: true and false.\n";
+      + "6. APP_QUIET_EXECUTION.            Whether commands should be executed in quiet mode. Valid values are: true and false.\n";
 
   /* 'sh' command */
   public static final String SH = "sh";
@@ -2593,11 +2593,11 @@ public class CliStrings {
 
   public static final String START_SERVER__MAX__CONNECTIONS = "max-connections";
   public static final String START_SERVER__MAX__CONNECTIONS__HELP =
-      "Sets the maxium number of client connections allowed. When the maximum is reached the cache server will stop accepting connections";
+      "Sets the maximum number of client connections allowed. When the maximum is reached the cache server will stop accepting connections";
 
   public static final String START_SERVER__MAX__THREADS = "max-threads";
   public static final String START_SERVER__MAX__THREADS__HELP =
-      "Sets the maxium number of threads allowed in this cache server to service client requests. The default of 0 causes the cache server to dedicate a thread for every client connection";
+      "Sets the maximum number of threads allowed in this cache server to service client requests. The default of 0 causes the cache server to dedicate a thread for every client connection";
 
   public static final String START_SERVER__MAX__MESSAGE__COUNT = "max-message-count";
   public static final String START_SERVER__MAX__MESSAGE__COUNT__HELP =
@@ -2699,7 +2699,7 @@ public class CliStrings {
   public static final String STATUS_SERVER__PID__HELP =
       "Process ID (PID) of the running Geode Cache Server. Deprecated: Since Geode1.2. Requires the JDK tools.jar which is not included on the classpath by default. Use --dir instead.";
 
-  /* stop gateway-reciver */
+  /* stop gateway-receiver */
   public static final String STOP_GATEWAYRECEIVER = "stop gateway-receiver";
   public static final String STOP_GATEWAYRECEIVER__HELP =
       "Stop the Gateway Receiver on a member or members.";
@@ -2797,7 +2797,7 @@ public class CliStrings {
   public static final String UPGRADE_OFFLINE_DISK_STORE__UPGRADE_ATTEMPTED_BUT_NOTHING_TO_UPGRADE =
       "Upgradation was attempted but nothing to upgrade.";
   public static final String UPGRADE_OFFLINE_DISK_STORE__ERROR_WHILE_UPGRADATION_REASON_0 =
-      "Error occurred while perfoming disk store upgrade. Reason: \"{0}\"";
+      "Error occurred while performing disk store upgrade. Reason: \"{0}\"";
   public static final String UPGRADE_OFFLINE_DISK_STORE__MSG__CANNOT_LOCATE_0_DISKSTORE_IN_1 =
       "Cannot locate disk store \"{0}\" in directory : \"{1}\"";
   public static final String UPGRADE_OFFLINE_DISK_STORE__MSG__DISKSTORE_IN_USE_COMPACT_DISKSTORE_CAN_BE_USED =
@@ -2914,7 +2914,7 @@ public class CliStrings {
   public static final String GATEWAY_RECEIVER_IS_NOT_RUNNING_ON_MEMBER_0 =
       "GatewayReceiver is not running on member {0}";
   public static final String GATEWAYS_ARE_NOT_AVAILABLE_IN_CLUSTER =
-      "GatewaySenders or GatewayRecievers are not available in cluster";
+      "GatewaySenders or GatewayReceivers are not available in cluster";
   public static final String GATEWAY_SENDER_0_COULD_NOT_BE_INVOKED_DUE_TO_1 =
       "Could not invoke start gateway sender {0} operation on members due to {1}";
   public static final String GATEWAY_SENDER_0_COULD_NOT_BE_STARTED_ON_MEMBER_DUE_TO_1 =
@@ -3010,9 +3010,9 @@ public class CliStrings {
   public static final String COUNT_DURABLE_CQ_EVENTS__NO__CQS__REGISTERED =
       "No cq's registered on this member";
   public static final String COUNT_DURABLE_CQ_EVENTS__SUBSCRIPTION__QUEUE__SIZE__CQ =
-      "subcription-queue-size for durable-cq : \"{0}\".";
+      "subscription-queue-size for durable-cq : \"{0}\".";
   public static final String COUNT_DURABLE_CQ_EVENTS__SUBSCRIPTION__QUEUE__SIZE__CLIENT =
-      "subcription-queue-size for durable-client : \"{0}\".";
+      "subscription-queue-size for durable-client : \"{0}\".";
 
   /***
    * Cluster Configuration commands
@@ -3180,6 +3180,6 @@ public class CliStrings {
   }
 
 
-  public static final String IGNORE_INTERCEPTORS = "ignoreInterCeptors";
+  public static final String IGNORE_INTERCEPTORS = "ignoreInterceptors";
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/CommandProcessor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/CommandProcessor.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/CommandProcessor.java
index e9c2736..2464b00 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/CommandProcessor.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/remote/CommandProcessor.java
@@ -14,6 +14,14 @@
  */
 package org.apache.geode.management.internal.cli.remote;
 
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.Properties;
+
+import org.springframework.shell.core.Parser;
+import org.springframework.shell.event.ParseResult;
+
 import org.apache.geode.internal.security.SecurityService;
 import org.apache.geode.internal.security.SecurityServiceFactory;
 import org.apache.geode.management.cli.CommandProcessingException;
@@ -27,13 +35,6 @@ import org.apache.geode.management.internal.cli.util.CommentSkipHelper;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.NotAuthorizedException;
 import org.apache.geode.security.ResourcePermission;
-import org.springframework.shell.core.Parser;
-import org.springframework.shell.event.ParseResult;
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.Map;
-import java.util.Properties;
 
 /**
  * @since GemFire 7.0
@@ -85,7 +86,7 @@ public class CommandProcessor {
   }
 
   public Result executeCommand(CommandStatement cmdStmt) {
-    Object result = null;
+    Object result;
     Result commandResult = null;
 
     CommentSkipHelper commentSkipper = new CommentSkipHelper();

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/security/MBeanServerWrapper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/security/MBeanServerWrapper.java b/geode-core/src/main/java/org/apache/geode/management/internal/security/MBeanServerWrapper.java
index 47260bc..7c3ecb8 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/security/MBeanServerWrapper.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/security/MBeanServerWrapper.java
@@ -14,17 +14,9 @@
  */
 package org.apache.geode.management.internal.security;
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.geode.internal.security.SecurityService;
-import org.apache.geode.management.internal.ManagementConstants;
-import org.apache.geode.security.GemFireSecurityException;
-import org.apache.geode.security.ResourcePermission;
-import org.apache.geode.security.ResourcePermission.Resource;
-import org.apache.geode.security.ResourcePermission.Operation;
-import org.apache.geode.security.ResourcePermission.Target;
-
 import java.io.ObjectInputStream;
 import java.util.Set;
+
 import javax.management.Attribute;
 import javax.management.AttributeList;
 import javax.management.AttributeNotFoundException;
@@ -51,6 +43,16 @@ import javax.management.ReflectionException;
 import javax.management.loading.ClassLoaderRepository;
 import javax.management.remote.MBeanServerForwarder;
 
+import org.apache.commons.lang.StringUtils;
+
+import org.apache.geode.internal.security.SecurityService;
+import org.apache.geode.management.internal.ManagementConstants;
+import org.apache.geode.security.GemFireSecurityException;
+import org.apache.geode.security.ResourcePermission;
+import org.apache.geode.security.ResourcePermission.Operation;
+import org.apache.geode.security.ResourcePermission.Resource;
+import org.apache.geode.security.ResourcePermission.Target;
+
 /**
  * This class intercepts all MBean requests for GemFire MBeans and passed it to
  * ManagementInterceptor for authorization
@@ -217,15 +219,13 @@ public class MBeanServerWrapper implements MBeanServerForwarder {
     ResourcePermission ctx = getOperationContext(name, operationName, true);
     this.securityService.authorize(ctx);
 
-    Object result = mbs.invoke(name, operationName, params, signature);
-
-    return result;
+    return mbs.invoke(name, operationName, params, signature);
   }
 
   // TODO: cache this
   private ResourcePermission getOperationContext(ObjectName objectName, String featureName,
       boolean isOp) throws InstanceNotFoundException, ReflectionException {
-    MBeanInfo beanInfo = null;
+    MBeanInfo beanInfo;
     try {
       beanInfo = mbs.getMBeanInfo(objectName);
     } catch (IntrospectionException e) {
@@ -238,7 +238,7 @@ public class MBeanServerWrapper implements MBeanServerForwarder {
     // find the context in the beanInfo if defined in the class level
     result = getOperationContext(beanInfo.getDescriptor(), result);
 
-    MBeanFeatureInfo[] featureInfos = null;
+    MBeanFeatureInfo[] featureInfos;
     if (isOp) {
       featureInfos = beanInfo.getOperations();
     } else {
@@ -262,8 +262,7 @@ public class MBeanServerWrapper implements MBeanServerForwarder {
     String targetCode = (String) descriptor.getFieldValue("target");
     if (resource != null && operationCode != null) {
       if (StringUtils.isBlank(targetCode)) {
-        return new ResourcePermission(Resource.valueOf(resource), Operation.valueOf(operationCode),
-            targetCode);
+        return new ResourcePermission(Resource.valueOf(resource), Operation.valueOf(operationCode));
       } else {
         return new ResourcePermission(Resource.valueOf(resource), Operation.valueOf(operationCode),
             Target.valueOf(targetCode).getName());
@@ -358,21 +357,20 @@ public class MBeanServerWrapper implements MBeanServerForwarder {
 
   @SuppressWarnings("deprecation")
   @Override
-  public ObjectInputStream deserialize(ObjectName name, byte[] data)
-      throws InstanceNotFoundException, OperationsException {
+  public ObjectInputStream deserialize(ObjectName name, byte[] data) throws OperationsException {
     return mbs.deserialize(name, data);
   }
 
   @Override
   public ObjectInputStream deserialize(String className, byte[] data)
       throws OperationsException, ReflectionException {
-    return deserialize(className, data);
+    return mbs.deserialize(className, data);
   }
 
   @SuppressWarnings("deprecation")
   @Override
   public ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] data)
-      throws InstanceNotFoundException, OperationsException, ReflectionException {
+      throws OperationsException, ReflectionException {
     return mbs.deserialize(className, loaderName, data);
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/MemberMBeanAttributesDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/MemberMBeanAttributesDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/MemberMBeanAttributesDUnitTest.java
index 94b049e..97f766e 100644
--- a/geode-core/src/test/java/org/apache/geode/management/MemberMBeanAttributesDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/MemberMBeanAttributesDUnitTest.java
@@ -14,18 +14,15 @@
  */
 package org.apache.geode.management;
 
-import org.junit.experimental.categories.Category;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-import org.apache.geode.test.junit.categories.DistributedTest;
-import org.apache.geode.test.junit.categories.FlakyTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import java.lang.management.ManagementFactory;
 
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionFactory;
 import org.apache.geode.cache.RegionShortcut;
@@ -37,6 +34,8 @@ import org.apache.geode.internal.process.ProcessUtils;
 import org.apache.geode.test.dunit.LogWriterUtils;
 import org.apache.geode.test.dunit.SerializableRunnable;
 import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.categories.FlakyTest;
 
 /**
  * This test class checks around 89 attributes of Member MBeans
@@ -81,8 +80,8 @@ public class MemberMBeanAttributesDUnitTest extends ManagementTestBase {
   @Test
   public void testReplRegionAttributes() throws Exception {
     initManagement(false);
-    setupForReplicateRegonAttributes(managedNodeList.get(0), 1);
-    setupForReplicateRegonAttributes(managedNodeList.get(1), 201);
+    setupForReplicateRegionAttributes(managedNodeList.get(0), 1);
+    setupForReplicateRegionAttributes(managedNodeList.get(1), 201);
     sample(managedNodeList.get(1));// Sample now
     isReplicatedRegionAttrsOK(managedNodeList.get(1));
 
@@ -92,7 +91,7 @@ public class MemberMBeanAttributesDUnitTest extends ManagementTestBase {
   @Test
   public void testPRRegionAttributes() throws Exception {
     initManagement(false);
-    setupForPartitionedRegonAttributes(managedNodeList.get(0), 1);
+    setupForPartitionedRegionAttributes(managedNodeList.get(0), 1);
     sample(managedNodeList.get(0));// Sample now
     isPartitionedRegionAttrsOK(managedNodeList.get(0));
 
@@ -112,7 +111,7 @@ public class MemberMBeanAttributesDUnitTest extends ManagementTestBase {
   }
 
 
-  public void setupForReplicateRegonAttributes(VM vm1, final int offset) throws Exception {
+  public void setupForReplicateRegionAttributes(VM vm1, final int offset) {
     vm1.invoke(new SerializableRunnable("Create Cache") {
       public void run() {
         GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
@@ -144,7 +143,7 @@ public class MemberMBeanAttributesDUnitTest extends ManagementTestBase {
 
   }
 
-  public void setupForPartitionedRegonAttributes(VM vm1, final int offset) throws Exception {
+  public void setupForPartitionedRegionAttributes(VM vm1, final int offset) {
     vm1.invoke(new SerializableRunnable("Create Cache") {
       public void run() {
         GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
@@ -177,7 +176,7 @@ public class MemberMBeanAttributesDUnitTest extends ManagementTestBase {
    * @throws Exception
    */
   @SuppressWarnings("serial")
-  public void isPartitionedRegionAttrsOK(VM vm1) throws Exception {
+  public void isPartitionedRegionAttrsOK(VM vm1) {
     vm1.invoke(new SerializableRunnable("Create Cache") {
       public void run() {
         MemberMXBean bean = managementService.getMemberMXBean();
@@ -197,7 +196,7 @@ public class MemberMBeanAttributesDUnitTest extends ManagementTestBase {
    * @throws Exception
    */
   @SuppressWarnings("serial")
-  public void isReplicatedRegionAttrsOK(VM vm1) throws Exception {
+  public void isReplicatedRegionAttrsOK(VM vm1) {
     vm1.invoke(new SerializableRunnable("Create Cache") {
       public void run() {
         MemberMXBean bean = managementService.getMemberMXBean();
@@ -220,7 +219,7 @@ public class MemberMBeanAttributesDUnitTest extends ManagementTestBase {
    * @throws Exception
    */
   @SuppressWarnings("serial")
-  public void isOSRelatedAttrsOK(VM vm1) throws Exception {
+  public void isOSRelatedAttrsOK(VM vm1) {
     vm1.invoke(new SerializableRunnable("Create Cache") {
       public void run() {
         MemberMXBean bean = managementService.getMemberMXBean();
@@ -259,7 +258,7 @@ public class MemberMBeanAttributesDUnitTest extends ManagementTestBase {
   }
 
   @SuppressWarnings("serial")
-  public void isConfigRelatedAttrsOK(VM vm1) throws Exception {
+  public void isConfigRelatedAttrsOK(VM vm1) {
     vm1.invoke(new SerializableRunnable("Create Cache") {
       public void run() {
         MemberMXBean bean = managementService.getMemberMXBean();

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/bean/stats/MemberLevelStatsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/bean/stats/MemberLevelStatsJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/bean/stats/MemberLevelStatsJUnitTest.java
index 4a6d16a..e430b49 100644
--- a/geode-core/src/test/java/org/apache/geode/management/bean/stats/MemberLevelStatsJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/bean/stats/MemberLevelStatsJUnitTest.java
@@ -30,12 +30,12 @@ import org.apache.geode.distributed.internal.DistributionStats;
 import org.apache.geode.distributed.internal.locks.DLockStats;
 import org.apache.geode.internal.NanoTimer;
 import org.apache.geode.internal.OSProcess;
-import org.apache.geode.internal.statistics.VMStatsContract;
 import org.apache.geode.internal.cache.CachePerfStats;
 import org.apache.geode.internal.cache.DiskStoreStats;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.PartitionedRegionStats;
 import org.apache.geode.internal.cache.execute.FunctionServiceStats;
+import org.apache.geode.internal.statistics.VMStatsContract;
 import org.apache.geode.internal.stats50.VMStats50;
 import org.apache.geode.management.ManagementService;
 import org.apache.geode.management.internal.beans.MemberMBeanBridge;
@@ -165,7 +165,7 @@ public class MemberLevelStatsJUnitTest extends MBeanStatsTestCase {
 
     sample();
 
-    assertEquals(1, getInitialImagesInProgres());
+    assertEquals(1, getInitialImagesInProgress());
     cachePerfStats.endGetInitialImage(startGIITime);
     cachePerfStats.endCacheListenerCall(startCacheListenerTime);
     cachePerfStats.endCacheWriterCall(startCacheWriterTime);
@@ -389,8 +389,8 @@ public class MemberLevelStatsJUnitTest extends MBeanStatsTestCase {
     return bridge.getInitialImageTime();
   }
 
-  private int getInitialImagesInProgres() {
-    return bridge.getInitialImagesInProgres();
+  private int getInitialImagesInProgress() {
+    return bridge.getInitialImagesInProgress();
   }
 
   private float getBytesReceivedRate() {


[17/46] geode git commit: GEODE-2861: Remove dead code

Posted by zh...@apache.org.
GEODE-2861: Remove dead code

* code removed related to shutting down DiskStoreTaskPool
* this closes #594


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

Branch: refs/heads/feature/GEM-1483
Commit: 5039e62af85795e5448fa746969d001782922cc9
Parents: b517ef8
Author: Nick Reich <nr...@pivotal.io>
Authored: Fri Jun 16 15:52:00 2017 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Wed Jun 21 08:28:06 2017 -0700

----------------------------------------------------------------------
 .../geode/internal/cache/DiskStoreImpl.java     | 26 ------------------
 .../geode/internal/cache/GemFireCacheImpl.java  | 28 --------------------
 2 files changed, 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/5039e62a/geode-core/src/main/java/org/apache/geode/internal/cache/DiskStoreImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DiskStoreImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/DiskStoreImpl.java
index 5a121a8..3e97d0e 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DiskStoreImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DiskStoreImpl.java
@@ -4615,32 +4615,6 @@ public class DiskStoreImpl implements DiskStore {
     return false;
   }
 
-  private void stopDiskStoreTaskPool() {
-    if (logger.isDebugEnabled()) {
-      logger.debug("Stopping DiskStoreTaskPool");
-    }
-    shutdownPool(diskStoreTaskPool);
-
-    // Allow the delayed writes to complete
-    delayedWritePool.shutdown();
-    try {
-      delayedWritePool.awaitTermination(1, TimeUnit.SECONDS);
-    } catch (InterruptedException ignore) {
-      Thread.currentThread().interrupt();
-    }
-  }
-
-  private void shutdownPool(ThreadPoolExecutor pool) {
-    // All the regions have already been closed
-    // so this pool shouldn't be doing anything.
-    List<Runnable> l = pool.shutdownNow();
-    for (Runnable runnable : l) {
-      if (l instanceof DiskStoreTask) {
-        ((DiskStoreTask) l).taskCancelled();
-      }
-    }
-  }
-
   public void writeRVVGC(DiskRegion dr, LocalRegion region) {
     acquireReadLock(dr);
     try {

http://git-wip-us.apache.org/repos/asf/geode/blob/5039e62a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
index 5eaa5a4..fe97685 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
@@ -2357,7 +2357,6 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
         if (this.queryMonitor != null) {
           this.queryMonitor.stopMonitoring();
         }
-        stopDiskStoreTaskPool();
 
       } finally {
         // NO DISTRIBUTED MESSAGING CAN BE DONE HERE!
@@ -2475,16 +2474,6 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
     }
   }
 
-  /**
-   * Used to guard access to compactorPool and set to true when cache is shutdown.
-   */
-  private final AtomicBoolean diskStoreTaskSync = new AtomicBoolean(false);
-
-  /**
-   * Lazily initialized. TODO: this is always null
-   */
-  private ThreadPoolExecutor diskStoreTaskPool = null;
-
   private final ConcurrentMap<String, DiskStoreImpl> diskStores = new ConcurrentHashMap<>();
 
   private final ConcurrentMap<String, DiskStoreImpl> regionOwnedDiskStores =
@@ -2593,23 +2582,6 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
     return allDiskStores;
   }
 
-  private void stopDiskStoreTaskPool() {
-    synchronized (this.diskStoreTaskSync) {
-      this.diskStoreTaskSync.set(true);
-      // All the regions have already been closed
-      // so this pool shouldn't be doing anything.
-      if (this.diskStoreTaskPool != null) {
-        List<Runnable> listOfRunnables = this.diskStoreTaskPool.shutdownNow();
-        for (Runnable runnable : listOfRunnables) {
-          // TODO: fix this for-loop and the one in DiskStoreImpl
-          if (listOfRunnables instanceof DiskStoreTask) {
-            ((DiskStoreTask) listOfRunnables).taskCancelled();
-          }
-        }
-      }
-    }
-  }
-
   private void stopServers() {
     final boolean isDebugEnabled = logger.isDebugEnabled();
     if (isDebugEnabled) {


[36/46] geode git commit: GEODE-2995: Handle stream of ProtoBuf encoded messages

Posted by zh...@apache.org.
GEODE-2995: Handle stream of ProtoBuf encoded messages

This for now exists in isolation, but will be hooked up with the code currently in review for GEODE-3075

Signed-off-by: Alexander Murmann <am...@pivotal.io>
Signed-off-by: Brian Rowe <br...@pivotal.io>


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

Branch: refs/heads/feature/GEM-1483
Commit: cdcc4d95634ae6377c0198cadba92f52cd436be0
Parents: 4ace36a
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Mon Jun 12 15:12:18 2017 -0700
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Mon Jun 26 09:26:22 2017 -0700

----------------------------------------------------------------------
 geode-protobuf/build.gradle                     |  64 ++++++++++
 .../org/apache/geode/ProtobufUtilities.java     |  34 ++++++
 .../org/apache/geode/protocol/OpsProcessor.java |  53 ++++++++
 .../InvalidProtocolMessageException.java        |  25 ++++
 .../handler/ProtobufStreamProcessor.java        |  61 ++++++++++
 .../geode/protocol/handler/ProtocolHandler.java |  27 +++++
 .../protobuf/ProtobufProtocolHandler.java       |  41 +++++++
 .../protocol/operations/OperationHandler.java   |  27 +++++
 .../ProtobufRequestOperationParser.java         |  33 +++++
 .../protobuf/GetRequestOperationHandler.java    |  59 +++++++++
 .../registry/OperationsHandlerRegistry.java     |  57 +++++++++
 ...rationHandlerAlreadyRegisteredException.java |  21 ++++
 .../OperationHandlerNotRegisteredException.java |  21 ++++
 .../ProtobufSerializationService.java           |  50 ++++++++
 .../serialization/SerializationService.java     |  27 +++++
 .../geode/serialization/SerializationType.java  |  36 ++++++
 .../apache/geode/serialization/TypeCodec.java   |  23 ++++
 .../geode/serialization/codec/BinaryCodec.java  |  35 ++++++
 .../geode/serialization/codec/BooleanCodec.java |  37 ++++++
 .../geode/serialization/codec/ByteCodec.java    |  37 ++++++
 .../geode/serialization/codec/DoubleCodec.java  |  37 ++++++
 .../geode/serialization/codec/FloatCodec.java   |  37 ++++++
 .../geode/serialization/codec/IntCodec.java     |  38 ++++++
 .../geode/serialization/codec/JSONCodec.java    |  37 ++++++
 .../geode/serialization/codec/LongCodec.java    |  37 ++++++
 .../geode/serialization/codec/ShortCodec.java   |  37 ++++++
 .../geode/serialization/codec/StringCodec.java  |  39 ++++++
 .../UnsupportedEncodingTypeException.java       |  21 ++++
 .../translation/EncodingTypeTranslator.java     |  83 +++++++++++++
 .../UnsupportedEncodingTypeException.java       |  21 ++++
 .../registry/SerializationCodecRegistry.java    |  61 ++++++++++
 .../CodecAlreadyRegisteredForTypeException.java |  21 ++++
 .../CodecNotRegisteredForTypeException.java     |  21 ++++
 geode-protobuf/src/main/proto/basicTypes.proto  |  60 +++++++++
 .../src/main/proto/clientProtocol.proto         |  87 +++++++++++++
 geode-protobuf/src/main/proto/region_API.proto  | 106 ++++++++++++++++
 geode-protobuf/src/main/proto/server_API.proto  |  37 ++++++
 ...pache.geode.protocol.handler.ProtocolHandler |   1 +
 ...e.geode.protocol.operations.OperationHandler |   1 +
 .../org.apache.geode.serialization.TypeCodec    |  10 ++
 .../geode/client/protocol/IntegrationTest.java  | 121 +++++++++++++++++++
 .../geode/client/protocol/MessageUtil.java      |  41 +++++++
 .../geode/client/protocol/OpsHandler.java       |  21 ++++
 .../geode/client/protocol/OpsProcessorTest.java |  64 ++++++++++
 .../ProtobufProtocolHandlerJUnitTest.java       |  88 ++++++++++++++
 .../GetRequestOperationHandlerTest.java         |  95 +++++++++++++++
 .../OperationsHandlerRegistryJUnitTest.java     |  94 ++++++++++++++
 .../ProtobufSerializationServiceImplTest.java   |  57 +++++++++
 .../codec/StringCodecJUnitTest.java             |  64 ++++++++++
 ...eToSerializationTypeTranslatorJUnitTest.java |  72 +++++++++++
 .../registry/CodecRegistryJUnitTest.java        | 113 +++++++++++++++++
 gradle/rat.gradle                               |   6 +-
 settings.gradle                                 |   4 +-
 53 files changed, 2394 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/build.gradle
----------------------------------------------------------------------
diff --git a/geode-protobuf/build.gradle b/geode-protobuf/build.gradle
new file mode 100644
index 0000000..2102f6a
--- /dev/null
+++ b/geode-protobuf/build.gradle
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+
+apply plugin: 'com.google.protobuf'
+apply plugin: 'idea'
+
+buildscript {
+    repositories {
+        mavenCentral()
+    }
+    dependencies {
+        classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.1'
+    }
+}
+
+dependencies {
+    provided project(':geode-core')
+    testCompile project(':geode-junit')
+    testCompile files(project(':geode-core').sourceSets.test.output)
+
+    testCompile 'org.powermock:powermock-core:' + project.'powermock.version'
+    testCompile 'org.powermock:powermock-module-junit4:' + project.'powermock.version'
+    testCompile 'org.powermock:powermock-api-mockito:' + project.'powermock.version'
+
+    compile 'com.google.protobuf:protobuf-java:3.3.1'
+}
+
+protobuf {
+    protoc {
+        // The artifact spec for the Protobuf Compiler
+        artifact = 'com.google.protobuf:protoc:3.0.0'
+    }
+    // this allows our spotless rule to skip this directory (hopefully rat too)
+    generatedFilesBaseDir = "$buildDir/generated-src/proto"
+}
+
+sourceSets {
+    main {
+
+        java {
+            srcDir 'build/generated-src/proto/main/java'
+        }
+    }
+}
+// let IntelliJ know where the generated sources are.
+idea {
+    module {
+        sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/ProtobufUtilities.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/ProtobufUtilities.java b/geode-protobuf/src/main/java/org/apache/geode/ProtobufUtilities.java
new file mode 100644
index 0000000..c25fc14
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/ProtobufUtilities.java
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+import com.google.protobuf.ByteString;
+
+import org.apache.geode.protocol.protobuf.BasicTypes;
+import org.apache.geode.protocol.protobuf.ClientProtocol;
+
+public abstract class ProtobufUtilities {
+  public static BasicTypes.EncodedValue getEncodedValue(BasicTypes.EncodingType resultEncodingType,
+      byte[] resultEncodedValue) {
+    return BasicTypes.EncodedValue.newBuilder().setEncodingType(resultEncodingType)
+        .setValue(ByteString.copyFrom(resultEncodedValue)).build();
+  }
+
+  public static ClientProtocol.Message wrapResponseWithDefaultHeader(
+      ClientProtocol.Response response) {
+    return ClientProtocol.Message.newBuilder()
+        .setMessageHeader(ClientProtocol.MessageHeader.newBuilder()).setResponse(response).build();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/protocol/OpsProcessor.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/OpsProcessor.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/OpsProcessor.java
new file mode 100644
index 0000000..999fdf0
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/OpsProcessor.java
@@ -0,0 +1,53 @@
+/*
+ * 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.protocol;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.protocol.operations.OperationHandler;
+import org.apache.geode.protocol.operations.ProtobufRequestOperationParser;
+import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry;
+import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException;
+import org.apache.geode.protocol.protobuf.ClientProtocol;
+import org.apache.geode.protocol.protobuf.RegionAPI;
+import org.apache.geode.serialization.SerializationService;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+
+public class OpsProcessor {
+  private final OperationsHandlerRegistry opsHandlerRegistry;
+  private final SerializationService serializationService;
+
+  public OpsProcessor(OperationsHandlerRegistry opsHandlerRegistry,
+      SerializationService serializationService) {
+    this.opsHandlerRegistry = opsHandlerRegistry;
+    this.serializationService = serializationService;
+  }
+
+  public ClientProtocol.Response process(ClientProtocol.Request request, Cache cache)
+      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
+    OperationHandler opsHandler = null;
+    try {
+      opsHandler = opsHandlerRegistry
+          .getOperationHandlerForOperationId(request.getRequestAPICase().getNumber());
+    } catch (OperationHandlerNotRegisteredException e) {
+      e.printStackTrace();
+    }
+
+    Object responseMessage = opsHandler.process(serializationService,
+        ProtobufRequestOperationParser.getRequestForOperationTypeID(request), cache);
+    return ClientProtocol.Response.newBuilder()
+        .setGetResponse((RegionAPI.GetResponse) responseMessage).build();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/protocol/exception/InvalidProtocolMessageException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/exception/InvalidProtocolMessageException.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/exception/InvalidProtocolMessageException.java
new file mode 100644
index 0000000..8f73f57
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/exception/InvalidProtocolMessageException.java
@@ -0,0 +1,25 @@
+/*
+ * 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.protocol.exception;
+
+public class InvalidProtocolMessageException extends Exception {
+  public InvalidProtocolMessageException(String message) {
+    super(message);
+  }
+
+  public InvalidProtocolMessageException(String message, Throwable cause) {
+    super(message, cause);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/ProtobufStreamProcessor.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/ProtobufStreamProcessor.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/ProtobufStreamProcessor.java
new file mode 100644
index 0000000..e459f76
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/ProtobufStreamProcessor.java
@@ -0,0 +1,61 @@
+/*
+ * 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.protocol.handler;
+
+import org.apache.geode.ProtobufUtilities;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.protocol.OpsProcessor;
+import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
+import org.apache.geode.protocol.handler.protobuf.ProtobufProtocolHandler;
+import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry;
+import org.apache.geode.protocol.operations.registry.exception.OperationHandlerAlreadyRegisteredException;
+import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException;
+import org.apache.geode.protocol.protobuf.ClientProtocol;
+import org.apache.geode.serialization.ProtobufSerializationService;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class ProtobufStreamProcessor {
+  ProtobufProtocolHandler protobufProtocolHandler;
+  OperationsHandlerRegistry registry;
+  ProtobufSerializationService protobufSerializationService;
+  OpsProcessor opsProcessor;
+
+  public ProtobufStreamProcessor()
+      throws OperationHandlerAlreadyRegisteredException, CodecAlreadyRegisteredForTypeException {
+    protobufProtocolHandler = new ProtobufProtocolHandler();
+    registry = new OperationsHandlerRegistry();
+    protobufSerializationService = new ProtobufSerializationService();
+    opsProcessor = new OpsProcessor(registry, protobufSerializationService);
+  }
+
+  public void processOneMessage(InputStream inputStream, OutputStream outputStream, Cache cache)
+      throws InvalidProtocolMessageException, OperationHandlerNotRegisteredException,
+      UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException, IOException {
+    ClientProtocol.Message message = protobufProtocolHandler.deserialize(inputStream);
+
+    ClientProtocol.Request request = message.getRequest();
+    ClientProtocol.Response response = opsProcessor.process(request, cache);
+
+    ClientProtocol.Message responseMessage =
+        ProtobufUtilities.wrapResponseWithDefaultHeader(response);
+    protobufProtocolHandler.serialize(responseMessage, outputStream);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/ProtocolHandler.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/ProtocolHandler.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/ProtocolHandler.java
new file mode 100644
index 0000000..4947a0a
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/ProtocolHandler.java
@@ -0,0 +1,27 @@
+/*
+ * 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.protocol.handler;
+
+import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public interface ProtocolHandler<T> {
+  T deserialize(InputStream inputStream) throws InvalidProtocolMessageException;
+
+  void serialize(T inputMessage, OutputStream outputStream) throws IOException;
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/protobuf/ProtobufProtocolHandler.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/protobuf/ProtobufProtocolHandler.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/protobuf/ProtobufProtocolHandler.java
new file mode 100644
index 0000000..f8c2abd
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/protobuf/ProtobufProtocolHandler.java
@@ -0,0 +1,41 @@
+/*
+ * 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.protocol.handler.protobuf;
+
+import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
+import org.apache.geode.protocol.handler.ProtocolHandler;
+import org.apache.geode.protocol.protobuf.ClientProtocol;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class ProtobufProtocolHandler implements ProtocolHandler<ClientProtocol.Message> {
+  @Override
+  public ClientProtocol.Message deserialize(InputStream inputStream)
+      throws InvalidProtocolMessageException {
+    try {
+      return ClientProtocol.Message.parseDelimitedFrom(inputStream);
+    } catch (IOException e) {
+      throw new InvalidProtocolMessageException("Failed to parse Protobuf Message", e);
+    }
+  }
+
+  @Override
+  public void serialize(ClientProtocol.Message inputMessage, OutputStream outputStream)
+      throws IOException {
+    inputMessage.writeDelimitedTo(outputStream);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/OperationHandler.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/OperationHandler.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/OperationHandler.java
new file mode 100644
index 0000000..020c27b
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/OperationHandler.java
@@ -0,0 +1,27 @@
+/*
+ * 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.protocol.operations;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.serialization.SerializationService;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+
+public interface OperationHandler<Req, Resp> {
+  Resp process(SerializationService serializationService, Req request, Cache cache)
+      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException;
+
+  int getOperationCode();
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/ProtobufRequestOperationParser.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/ProtobufRequestOperationParser.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/ProtobufRequestOperationParser.java
new file mode 100644
index 0000000..7fb0eab
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/ProtobufRequestOperationParser.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.protocol.operations;
+
+import org.apache.geode.protocol.protobuf.ClientProtocol;
+
+public class ProtobufRequestOperationParser {
+  public static Object getRequestForOperationTypeID(ClientProtocol.Request request) {
+    switch (request.getRequestAPICase()) {
+      case PUTREQUEST:
+        return request.getPutRequest();
+      case GETREQUEST:
+        return request.getGetRequest();
+      case PUTALLREQUEST:
+        return request.getPutAllRequest();
+      default:
+        throw new RuntimeException(
+            "Unknown request type: " + request.getRequestAPICase().getNumber());
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandler.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandler.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandler.java
new file mode 100644
index 0000000..dafacc0
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandler.java
@@ -0,0 +1,59 @@
+/*
+ * 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.protocol.operations.protobuf;
+
+import org.apache.geode.ProtobufUtilities;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionService;
+import org.apache.geode.protocol.operations.OperationHandler;
+import org.apache.geode.protocol.protobuf.BasicTypes;
+import org.apache.geode.protocol.protobuf.ClientProtocol;
+import org.apache.geode.protocol.protobuf.RegionAPI;
+import org.apache.geode.serialization.SerializationService;
+import org.apache.geode.serialization.protobuf.translation.EncodingTypeTranslator;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+
+public class GetRequestOperationHandler
+    implements OperationHandler<RegionAPI.GetRequest, RegionAPI.GetResponse> {
+
+  @Override
+  public RegionAPI.GetResponse process(SerializationService serializationService,
+      RegionAPI.GetRequest request, Cache cache)
+      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
+    String regionName = request.getRegionName();
+    BasicTypes.EncodedValue key = request.getKey();
+    BasicTypes.EncodingType encodingType = key.getEncodingType();
+    byte[] value = key.getValue().toByteArray();
+    Object decodedValue = serializationService.decode(encodingType, value);
+
+    Region region = cache.getRegion(regionName);
+    Object resultValue = region.get(decodedValue);
+
+    BasicTypes.EncodingType resultEncodingType =
+        EncodingTypeTranslator.getEncodingTypeForObject(resultValue);
+    byte[] resultEncodedValue = serializationService.encode(resultEncodingType, resultValue);
+
+    return RegionAPI.GetResponse.newBuilder()
+        .setResult(ProtobufUtilities.getEncodedValue(resultEncodingType, resultEncodedValue))
+        .build();
+  }
+
+  @Override
+  public int getOperationCode() {
+    return ClientProtocol.Request.RequestAPICase.GETREQUEST.getNumber();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/OperationsHandlerRegistry.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/OperationsHandlerRegistry.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/OperationsHandlerRegistry.java
new file mode 100644
index 0000000..80e0459
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/OperationsHandlerRegistry.java
@@ -0,0 +1,57 @@
+/*
+ * 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.protocol.operations.registry;
+
+import org.apache.geode.protocol.operations.OperationHandler;
+import org.apache.geode.protocol.operations.registry.exception.OperationHandlerAlreadyRegisteredException;
+import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException;
+
+import java.util.HashMap;
+import java.util.ServiceLoader;
+
+public class OperationsHandlerRegistry {
+  private HashMap<Integer, OperationHandler> registeredOperations = new HashMap<>();
+
+  public OperationsHandlerRegistry() throws OperationHandlerAlreadyRegisteredException {
+    ServiceLoader<OperationHandler> operationHandlers = ServiceLoader.load(OperationHandler.class);
+    for (OperationHandler operationHandler : operationHandlers) {
+      registerOperationHandlerForOperationId(operationHandler.getOperationCode(), operationHandler);
+    }
+  }
+
+  public OperationHandler getOperationHandlerForOperationId(int operationCode)
+      throws OperationHandlerNotRegisteredException {
+    OperationHandler operationHandler = registeredOperations.get(operationCode);
+    if (operationHandler == null) {
+      throw new OperationHandlerNotRegisteredException(
+          "There is no operation handler registered for operation code: " + operationCode);
+    }
+    return operationHandler;
+  }
+
+  public synchronized void registerOperationHandlerForOperationId(int operationCode,
+      OperationHandler operationHandler) throws OperationHandlerAlreadyRegisteredException {
+    if (registeredOperations.containsKey(operationCode)) {
+      throw new OperationHandlerAlreadyRegisteredException(
+          "An operation handler for operationCode: " + operationCode
+              + " has already been registered!");
+    }
+    registeredOperations.put(operationCode, operationHandler);
+  }
+
+  public int getRegisteredOperationHandlersCount() {
+    return registeredOperations.size();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerAlreadyRegisteredException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerAlreadyRegisteredException.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerAlreadyRegisteredException.java
new file mode 100644
index 0000000..1f42c10
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerAlreadyRegisteredException.java
@@ -0,0 +1,21 @@
+/*
+ * 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.protocol.operations.registry.exception;
+
+public class OperationHandlerAlreadyRegisteredException extends Exception {
+  public OperationHandlerAlreadyRegisteredException(String message) {
+    super(message);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerNotRegisteredException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerNotRegisteredException.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerNotRegisteredException.java
new file mode 100644
index 0000000..f83e1b3
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerNotRegisteredException.java
@@ -0,0 +1,21 @@
+/*
+ * 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.protocol.operations.registry.exception;
+
+public class OperationHandlerNotRegisteredException extends Exception {
+  public OperationHandlerNotRegisteredException(String message) {
+    super(message);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/ProtobufSerializationService.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/ProtobufSerializationService.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/ProtobufSerializationService.java
new file mode 100644
index 0000000..9d78245
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/ProtobufSerializationService.java
@@ -0,0 +1,50 @@
+/*
+ * 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.serialization;
+
+import org.apache.geode.protocol.protobuf.BasicTypes;
+import org.apache.geode.serialization.protobuf.translation.EncodingTypeTranslator;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.SerializationCodecRegistry;
+import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+
+public class ProtobufSerializationService implements SerializationService<BasicTypes.EncodingType> {
+  private SerializationCodecRegistry serializationCodecRegistry = new SerializationCodecRegistry();
+
+  public ProtobufSerializationService() throws CodecAlreadyRegisteredForTypeException {}
+
+  @Override
+  public byte[] encode(BasicTypes.EncodingType encodingTypeValue, Object value)
+      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
+    TypeCodec codecForType = getTypeCodecForProtobufType(encodingTypeValue);
+    return codecForType.encode(value);
+  }
+
+  @Override
+  public Object decode(BasicTypes.EncodingType encodingTypeValue, byte[] value)
+      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
+    TypeCodec codecForType = getTypeCodecForProtobufType(encodingTypeValue);
+    return codecForType.decode(value);
+  }
+
+  private TypeCodec getTypeCodecForProtobufType(BasicTypes.EncodingType encodingTypeValue)
+      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
+    SerializationType serializationTypeForEncodingType =
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(encodingTypeValue);
+
+    return serializationCodecRegistry.getCodecForType(serializationTypeForEncodingType);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationService.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationService.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationService.java
new file mode 100644
index 0000000..623a7bd
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationService.java
@@ -0,0 +1,27 @@
+/*
+ * 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.serialization;
+
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+
+public interface SerializationService<T> {
+
+  Object decode(T encodingTypeValue, byte[] value)
+      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException;
+
+  byte[] encode(T encodingTypeValue, Object value)
+      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException;
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java
new file mode 100644
index 0000000..4ea4422
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java
@@ -0,0 +1,36 @@
+/*
+ * 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.serialization;
+
+import org.apache.geode.pdx.PdxInstance;
+
+public enum SerializationType {
+  STRING(String.class),
+  BINARY(byte[].class),
+  INT(int.class),
+  BYTE(byte.class),
+  SHORT(short.class),
+  LONG(long.class),
+  JSON(PdxInstance.class),
+  BOOLEAN(boolean.class),
+  FLOAT(float.class),
+  DOUBLE(double.class);
+
+  public final Class klass;
+
+  SerializationType(Class klass) {
+    this.klass = klass;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/TypeCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/TypeCodec.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/TypeCodec.java
new file mode 100644
index 0000000..f2c7f90
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/TypeCodec.java
@@ -0,0 +1,23 @@
+/*
+ * 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.serialization;
+
+public interface TypeCodec<T> {
+  T decode(byte[] incoming);
+
+  byte[] encode(T incoming);
+
+  SerializationType getSerializationType();
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/BinaryCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/BinaryCodec.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/BinaryCodec.java
new file mode 100644
index 0000000..c1bee43
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/BinaryCodec.java
@@ -0,0 +1,35 @@
+/*
+ * 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.serialization.codec;
+
+import org.apache.geode.serialization.SerializationType;
+import org.apache.geode.serialization.TypeCodec;
+
+public class BinaryCodec implements TypeCodec<byte[]> {
+  @Override
+  public byte[] decode(byte[] incoming) {
+    return incoming;
+  }
+
+  @Override
+  public byte[] encode(byte[] incoming) {
+    return incoming;
+  }
+
+  @Override
+  public SerializationType getSerializationType() {
+    return SerializationType.BINARY;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/BooleanCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/BooleanCodec.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/BooleanCodec.java
new file mode 100644
index 0000000..e3e234d
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/BooleanCodec.java
@@ -0,0 +1,37 @@
+/*
+ * 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.serialization.codec;
+
+import org.apache.geode.serialization.SerializationType;
+import org.apache.geode.serialization.TypeCodec;
+
+import java.nio.ByteBuffer;
+
+public class BooleanCodec implements TypeCodec<Boolean> {
+  @Override
+  public Boolean decode(byte[] incoming) {
+    return ByteBuffer.wrap(incoming).get() == 1;
+  }
+
+  @Override
+  public byte[] encode(Boolean incoming) {
+    return ByteBuffer.allocate(Byte.BYTES).put(incoming ? (byte) 1 : (byte) 0).array();
+  }
+
+  @Override
+  public SerializationType getSerializationType() {
+    return SerializationType.BOOLEAN;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/ByteCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/ByteCodec.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/ByteCodec.java
new file mode 100644
index 0000000..10db041
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/ByteCodec.java
@@ -0,0 +1,37 @@
+/*
+ * 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.serialization.codec;
+
+import org.apache.geode.serialization.SerializationType;
+import org.apache.geode.serialization.TypeCodec;
+
+import java.nio.ByteBuffer;
+
+public class ByteCodec implements TypeCodec<Byte> {
+  @Override
+  public Byte decode(byte[] incoming) {
+    return ByteBuffer.wrap(incoming).get();
+  }
+
+  @Override
+  public byte[] encode(Byte incoming) {
+    return ByteBuffer.allocate(Byte.BYTES).put(incoming).array();
+  }
+
+  @Override
+  public SerializationType getSerializationType() {
+    return SerializationType.BYTE;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/DoubleCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/DoubleCodec.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/DoubleCodec.java
new file mode 100644
index 0000000..0bcb852
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/DoubleCodec.java
@@ -0,0 +1,37 @@
+/*
+ * 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.serialization.codec;
+
+import org.apache.geode.serialization.SerializationType;
+import org.apache.geode.serialization.TypeCodec;
+
+import java.nio.ByteBuffer;
+
+public class DoubleCodec implements TypeCodec<Double> {
+  @Override
+  public Double decode(byte[] incoming) {
+    return ByteBuffer.wrap(incoming).getDouble();
+  }
+
+  @Override
+  public byte[] encode(Double incoming) {
+    return ByteBuffer.allocate(Double.BYTES).putDouble(incoming).array();
+  }
+
+  @Override
+  public SerializationType getSerializationType() {
+    return SerializationType.DOUBLE;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/FloatCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/FloatCodec.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/FloatCodec.java
new file mode 100644
index 0000000..c41914b
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/FloatCodec.java
@@ -0,0 +1,37 @@
+/*
+ * 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.serialization.codec;
+
+import org.apache.geode.serialization.SerializationType;
+import org.apache.geode.serialization.TypeCodec;
+
+import java.nio.ByteBuffer;
+
+public class FloatCodec implements TypeCodec<Float> {
+  @Override
+  public Float decode(byte[] incoming) {
+    return ByteBuffer.wrap(incoming).getFloat();
+  }
+
+  @Override
+  public byte[] encode(Float incoming) {
+    return ByteBuffer.allocate(Float.BYTES).putFloat(incoming).array();
+  }
+
+  @Override
+  public SerializationType getSerializationType() {
+    return SerializationType.FLOAT;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/IntCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/IntCodec.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/IntCodec.java
new file mode 100644
index 0000000..6bd2b5c
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/IntCodec.java
@@ -0,0 +1,38 @@
+/*
+ * 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.serialization.codec;
+
+import org.apache.geode.serialization.SerializationType;
+import org.apache.geode.serialization.TypeCodec;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+
+public class IntCodec implements TypeCodec<Integer> {
+  @Override
+  public Integer decode(byte[] incoming) {
+    return ByteBuffer.wrap(incoming).getInt();
+  }
+
+  @Override
+  public byte[] encode(Integer incoming) {
+    return ByteBuffer.allocate(Integer.BYTES).putInt(incoming).array();
+  }
+
+  @Override
+  public SerializationType getSerializationType() {
+    return SerializationType.INT;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/JSONCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/JSONCodec.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/JSONCodec.java
new file mode 100644
index 0000000..eb1ebc3
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/JSONCodec.java
@@ -0,0 +1,37 @@
+/*
+ * 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.serialization.codec;
+
+import org.apache.geode.pdx.JSONFormatter;
+import org.apache.geode.pdx.PdxInstance;
+import org.apache.geode.serialization.SerializationType;
+import org.apache.geode.serialization.TypeCodec;
+
+public class JSONCodec implements TypeCodec<PdxInstance> {
+  @Override
+  public PdxInstance decode(byte[] incoming) {
+    return JSONFormatter.fromJSON(incoming);
+  }
+
+  @Override
+  public byte[] encode(PdxInstance incoming) {
+    return JSONFormatter.toJSONByteArray(incoming);
+  }
+
+  @Override
+  public SerializationType getSerializationType() {
+    return SerializationType.JSON;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/LongCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/LongCodec.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/LongCodec.java
new file mode 100644
index 0000000..9b064a7
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/LongCodec.java
@@ -0,0 +1,37 @@
+/*
+ * 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.serialization.codec;
+
+import org.apache.geode.serialization.SerializationType;
+import org.apache.geode.serialization.TypeCodec;
+
+import java.nio.ByteBuffer;
+
+public class LongCodec implements TypeCodec<Long> {
+  @Override
+  public Long decode(byte[] incoming) {
+    return ByteBuffer.wrap(incoming).getLong();
+  }
+
+  @Override
+  public byte[] encode(Long incoming) {
+    return ByteBuffer.allocate(Long.BYTES).putLong(incoming).array();
+  }
+
+  @Override
+  public SerializationType getSerializationType() {
+    return SerializationType.LONG;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/ShortCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/ShortCodec.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/ShortCodec.java
new file mode 100644
index 0000000..8d7b1d4
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/ShortCodec.java
@@ -0,0 +1,37 @@
+/*
+ * 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.serialization.codec;
+
+import org.apache.geode.serialization.SerializationType;
+import org.apache.geode.serialization.TypeCodec;
+
+import java.nio.ByteBuffer;
+
+public class ShortCodec implements TypeCodec<Short> {
+  @Override
+  public Short decode(byte[] incoming) {
+    return ByteBuffer.wrap(incoming).getShort();
+  }
+
+  @Override
+  public byte[] encode(Short incoming) {
+    return ByteBuffer.allocate(Short.BYTES).putShort(incoming).array();
+  }
+
+  @Override
+  public SerializationType getSerializationType() {
+    return SerializationType.SHORT;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/StringCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/StringCodec.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/StringCodec.java
new file mode 100644
index 0000000..cc7904b
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/StringCodec.java
@@ -0,0 +1,39 @@
+/*
+ * 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.serialization.codec;
+
+import org.apache.geode.serialization.SerializationType;
+import org.apache.geode.serialization.TypeCodec;
+
+import java.nio.charset.Charset;
+
+public class StringCodec implements TypeCodec<String> {
+  private static final Charset UTF8 = Charset.forName("UTF-8");
+
+  @Override
+  public String decode(byte[] incoming) {
+    return new String(incoming, UTF8);
+  }
+
+  @Override
+  public byte[] encode(String incoming) {
+    return incoming.getBytes(UTF8);
+  }
+
+  @Override
+  public SerializationType getSerializationType() {
+    return SerializationType.STRING;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/exception/UnsupportedEncodingTypeException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/exception/UnsupportedEncodingTypeException.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/exception/UnsupportedEncodingTypeException.java
new file mode 100644
index 0000000..9d75f56
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/exception/UnsupportedEncodingTypeException.java
@@ -0,0 +1,21 @@
+/*
+ * 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.serialization.exception;
+
+public class UnsupportedEncodingTypeException extends Exception {
+  public UnsupportedEncodingTypeException(String message) {
+    super(message);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeTranslator.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeTranslator.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeTranslator.java
new file mode 100644
index 0000000..667996d
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeTranslator.java
@@ -0,0 +1,83 @@
+/*
+ * 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.serialization.protobuf.translation;
+
+import org.apache.geode.pdx.JSONFormatter;
+import org.apache.geode.pdx.PdxInstance;
+import org.apache.geode.protocol.protobuf.BasicTypes;
+import org.apache.geode.serialization.SerializationType;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+
+public abstract class EncodingTypeTranslator {
+  public static SerializationType getSerializationTypeForEncodingType(
+      BasicTypes.EncodingType encodingType) throws UnsupportedEncodingTypeException {
+    switch (encodingType) {
+      case INT:
+        return SerializationType.INT;
+      case BYTE:
+        return SerializationType.BYTE;
+      case JSON:
+        return SerializationType.JSON;
+      case LONG:
+        return SerializationType.LONG;
+      case FLOAT:
+        return SerializationType.FLOAT;
+      case SHORT:
+        return SerializationType.SHORT;
+      case BINARY:
+        return SerializationType.BINARY;
+      case DOUBLE:
+        return SerializationType.DOUBLE;
+      case STRING:
+        return SerializationType.STRING;
+      case BOOLEAN:
+        return SerializationType.BOOLEAN;
+      default:
+        throw new UnsupportedEncodingTypeException(
+            "No serialization type found for protobuf encoding type: " + encodingType);
+    }
+  }
+
+  public static BasicTypes.EncodingType getEncodingTypeForObject(Object resultValue)
+      throws UnsupportedEncodingTypeException {
+    if (resultValue instanceof Integer) {
+      return BasicTypes.EncodingType.INT;
+    } else if (resultValue instanceof Byte) {
+      return BasicTypes.EncodingType.BYTE;
+    } else if (resultValue instanceof PdxInstance) {
+      String pdxClassName = ((PdxInstance) resultValue).getClassName();
+      if (pdxClassName.equals(JSONFormatter.JSON_CLASSNAME)) {
+        return BasicTypes.EncodingType.JSON;
+      }
+    } else if (resultValue instanceof Long) {
+      return BasicTypes.EncodingType.LONG;
+    } else if (resultValue instanceof Float) {
+      return BasicTypes.EncodingType.FLOAT;
+    } else if (resultValue instanceof Short) {
+      return BasicTypes.EncodingType.SHORT;
+    } else if (resultValue instanceof byte[]) {
+      return BasicTypes.EncodingType.BINARY;
+    } else if (resultValue instanceof Double) {
+      return BasicTypes.EncodingType.DOUBLE;
+    } else if (resultValue instanceof String) {
+      return BasicTypes.EncodingType.STRING;
+    } else if (resultValue instanceof Boolean) {
+      return BasicTypes.EncodingType.BOOLEAN;
+    }
+
+    throw new UnsupportedEncodingTypeException(
+        "We cannot translate: " + resultValue.getClass() + " into a specific Protobuf Encoding");
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/exception/UnsupportedEncodingTypeException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/exception/UnsupportedEncodingTypeException.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/exception/UnsupportedEncodingTypeException.java
new file mode 100644
index 0000000..ad01eac
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/exception/UnsupportedEncodingTypeException.java
@@ -0,0 +1,21 @@
+/*
+ * 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.serialization.protobuf.translation.exception;
+
+public class UnsupportedEncodingTypeException extends Exception {
+  public UnsupportedEncodingTypeException(String message) {
+    super(message);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/SerializationCodecRegistry.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/SerializationCodecRegistry.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/SerializationCodecRegistry.java
new file mode 100644
index 0000000..2c88306
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/SerializationCodecRegistry.java
@@ -0,0 +1,61 @@
+/*
+ * 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.serialization.registry;
+
+import org.apache.geode.serialization.SerializationType;
+import org.apache.geode.serialization.TypeCodec;
+import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+
+import java.util.HashMap;
+import java.util.ServiceLoader;
+
+public class SerializationCodecRegistry {
+  private HashMap<SerializationType, TypeCodec> codecRegistry = new HashMap<>();
+
+  public SerializationCodecRegistry() throws CodecAlreadyRegisteredForTypeException {
+    ServiceLoader<TypeCodec> typeCodecs = ServiceLoader.load(TypeCodec.class);
+    for (TypeCodec typeCodec : typeCodecs) {
+      register(typeCodec.getSerializationType(), typeCodec);
+    }
+  }
+
+  public synchronized void register(SerializationType serializationType, TypeCodec<?> typeCodec)
+      throws CodecAlreadyRegisteredForTypeException {
+    if (codecRegistry.containsKey(serializationType)) {
+      throw new CodecAlreadyRegisteredForTypeException(
+          "There is already a codec registered for type: " + serializationType);
+    }
+    codecRegistry.put(serializationType, typeCodec);
+  }
+
+  public int getRegisteredCodecCount() {
+    return codecRegistry.size();
+  }
+
+  public TypeCodec getCodecForType(SerializationType serializationType)
+      throws CodecNotRegisteredForTypeException {
+    TypeCodec typeCodec = codecRegistry.get(serializationType);
+    if (typeCodec == null) {
+      throw new CodecNotRegisteredForTypeException(
+          "There is no codec registered for type: " + serializationType);
+    }
+    return typeCodec;
+  }
+
+  public void shutdown() {
+    codecRegistry.clear();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecAlreadyRegisteredForTypeException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecAlreadyRegisteredForTypeException.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecAlreadyRegisteredForTypeException.java
new file mode 100644
index 0000000..678d374
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecAlreadyRegisteredForTypeException.java
@@ -0,0 +1,21 @@
+/*
+ * 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.serialization.registry.exception;
+
+public class CodecAlreadyRegisteredForTypeException extends Exception {
+  public CodecAlreadyRegisteredForTypeException(String message) {
+    super(message);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecNotRegisteredForTypeException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecNotRegisteredForTypeException.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecNotRegisteredForTypeException.java
new file mode 100644
index 0000000..a1a6408
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecNotRegisteredForTypeException.java
@@ -0,0 +1,21 @@
+/*
+ * 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.serialization.registry.exception;
+
+public class CodecNotRegisteredForTypeException extends Exception {
+  public CodecNotRegisteredForTypeException(String message) {
+    super(message);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/proto/basicTypes.proto
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/proto/basicTypes.proto b/geode-protobuf/src/main/proto/basicTypes.proto
new file mode 100644
index 0000000..502e28e
--- /dev/null
+++ b/geode-protobuf/src/main/proto/basicTypes.proto
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+syntax = "proto3";
+package org.apache.geode.protocol.protobuf;
+
+import "google/protobuf/any.proto";
+import "google/protobuf/empty.proto";
+
+message Entry {
+    EncodedValue key = 1;
+    EncodedValue value = 2;
+}
+
+message EncodedValue {
+    EncodingType encodingType = 1;
+    bytes value = 2;
+}
+
+enum EncodingType {
+    INVALID = 0;
+    INT = 1;
+    LONG = 2;
+    SHORT = 3;
+    BYTE = 4;
+    BOOLEAN = 5;
+    BINARY = 6;
+    FLOAT = 7;
+    DOUBLE = 8;
+    STRING = 9;
+    JSON = 10;
+}
+
+message CallbackArguments {
+    oneof callbackArgs {
+        google.protobuf.Empty hasCallbackArgument = 1;
+        EncodedValue callbackValue = 2;
+    }
+}
+
+message Region {
+    string name = 1;
+    // TODO: key, value types?
+}
+
+message Server {
+    string url = 1;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/proto/clientProtocol.proto
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/proto/clientProtocol.proto b/geode-protobuf/src/main/proto/clientProtocol.proto
new file mode 100644
index 0000000..0c19295
--- /dev/null
+++ b/geode-protobuf/src/main/proto/clientProtocol.proto
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+syntax = "proto3";
+package org.apache.geode.protocol.protobuf;
+
+import "google/protobuf/any.proto";
+import "region_API.proto";
+import "server_API.proto";
+import "basicTypes.proto";
+
+message Message {
+    MessageHeader messageHeader = 1;
+    oneof messageType {
+        Request request = 2;
+        Response response = 3;
+    }
+}
+
+message MessageHeader {
+    int32 correlationId = 1;
+    MetaData metadata = 2;
+}
+
+message Request {
+    CallbackArguments callbackArg = 1;
+    oneof requestAPI {
+        PutRequest putRequest = 2;
+        GetRequest getRequest = 3;
+        PutAllRequest putAllRequest = 4;
+        GetAllRequest getAllRequest = 5;
+        RemoveRequest removeRequest = 6;
+        RemoveAllRequest removeAllRequest = 7;
+        ListKeysRequest listKeysRequest = 8;
+
+        CreateRegionRequest createRegionRequest = 21;
+        DestroyRegionRequest destroyRegionRequest = 22;
+
+        PingRequest pingRequest = 41;
+        GetServersRequest getServersRequest = 42;
+        GetRegionsRequest getRegionsRequest = 43;
+    }
+}
+
+message Response {
+    ResponseHeader responseHeader = 1;
+    oneof responseAPI {
+        PutResponse putResponse = 2;
+        GetResponse getResponse = 3;
+        PutAllResponse putAllResponse = 4;
+        GetAllResponse getAllResponse = 5;
+        RemoveResponse removeResponse = 6;
+        RemoveAllResponse removeAllResponse = 7;
+        ListKeysResponse listKeysResponse = 8;
+
+        CreateRegionResponse createRegionResponse = 20;
+        DestroyRegionResponse destroyRegionResponse = 21;
+
+        PingResponse pingResponse = 41;
+        GetServersResponse getServersResponse = 42;
+        GetRegionsResponse getRegionsResponse = 43;
+    }
+}
+
+message ResponseHeader {
+    oneof reponseType {
+        int32 responseTypeID = 1;
+        int32 errorCode = 2;
+    }
+}
+
+message MetaData {
+    int32 numberOfMetadata = 1;
+    map<int32, google.protobuf.Any> metaDataEntries = 2;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/proto/region_API.proto
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/proto/region_API.proto b/geode-protobuf/src/main/proto/region_API.proto
new file mode 100644
index 0000000..52291c4
--- /dev/null
+++ b/geode-protobuf/src/main/proto/region_API.proto
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+syntax = "proto3";
+package org.apache.geode.protocol.protobuf;
+
+import "basicTypes.proto";
+
+message PutRequest {
+    string regionName = 1;
+    Entry entry = 2;
+}
+
+message PutResponse {
+    bool success = 1;
+}
+
+message GetRequest {
+    string regionName = 1;
+    EncodedValue key = 2;
+}
+
+message GetResponse {
+    EncodedValue result = 1;
+}
+
+message PutAllRequest {
+    string regionName = 1;
+    repeated Entry entry = 2;
+}
+
+message PutAllResponse {
+    repeated EncodedValue failedKeys = 1;
+}
+
+message GetAllRequest {
+    string regionName = 1;
+    repeated EncodedValue key = 2;
+    EncodedValue callbackArg = 3;
+}
+
+message GetAllResponse {
+    repeated Entry entries = 1;
+}
+
+message ListKeysRequest {
+    string regionName = 1;
+}
+
+message ListKeysResponse {
+    repeated EncodedValue key = 1;
+}
+
+message RemoveRequest {
+    string regionName = 1;
+    EncodedValue key = 2;
+}
+
+message RemoveResponse {
+    bool success = 1;
+}
+
+message RemoveAllRequest {
+    string regionName = 1;
+    repeated EncodedValue key = 2;
+}
+
+message RemoveAllResponse {
+    bool success = 1;
+}
+
+message CreateRegionRequest {
+    string regionName = 1;
+}
+
+message CreateRegionResponse {
+    bool success = 1;
+}
+
+message DestroyRegionRequest {
+    string regionName = 1;
+}
+
+message DestroyRegionResponse {
+    bool success = 1;
+}
+
+message GetRegionsRequest {
+
+}
+
+message GetRegionsResponse {
+    repeated Region regions = 1;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/proto/server_API.proto
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/proto/server_API.proto b/geode-protobuf/src/main/proto/server_API.proto
new file mode 100644
index 0000000..d957921
--- /dev/null
+++ b/geode-protobuf/src/main/proto/server_API.proto
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+syntax = "proto3";
+package org.apache.geode.protocol.protobuf;
+
+import "basicTypes.proto";
+
+// PingResponse sends the same number back.
+message PingRequest {
+    int32 sequenceNumber = 1;
+}
+
+message PingResponse {
+    int32 sequenceNumber = 1;
+}
+
+message GetServersRequest {
+
+}
+
+message GetServersResponse {
+    int32 numberOfServers = 1;
+    repeated Server servers = 2;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.handler.ProtocolHandler
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.handler.ProtocolHandler b/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.handler.ProtocolHandler
new file mode 100644
index 0000000..9af7c5d
--- /dev/null
+++ b/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.handler.ProtocolHandler
@@ -0,0 +1 @@
+org.apache.geode.protocol.handler.protobuf.ProtobufProtocolHandler
\ No newline at end of file


[29/46] geode git commit: GEODE-2924: fix lucene commands security test

Posted by zh...@apache.org.
GEODE-2924: fix lucene commands security test


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

Branch: refs/heads/feature/GEM-1483
Commit: 8053450143007ffaa7d92ae23d9e289129b97f56
Parents: 451d12e
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Fri Jun 23 17:56:27 2017 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Fri Jun 23 17:57:13 2017 -0700

----------------------------------------------------------------------
 .../geode/internal/util/PasswordUtil.java       |  27 +-
 .../lucene/LuceneClientSecurityDUnitTest.java   |  46 ++-
 .../lucene/LuceneCommandsSecurityDUnitTest.java | 291 -------------------
 .../lucene/LuceneCommandsSecurityTest.java      | 263 +++++++++++++++++
 4 files changed, 296 insertions(+), 331 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/80534501/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java b/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
index 5cc3bcd..2495959 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
@@ -49,23 +49,20 @@ public class PasswordUtil {
    */
   @Deprecated
   public static String decrypt(String password) {
-    String toDecrypt;
     if (password.startsWith("encrypted(") && password.endsWith(")")) {
-      toDecrypt = password.substring(10, password.length() - 1);
-    } else {
-      toDecrypt = password;
+      byte[] decrypted = null;
+      try {
+        String toDecrypt = password.substring(10, password.length() - 1);
+        SecretKeySpec key = new SecretKeySpec(init, "Blowfish");
+        Cipher cipher = Cipher.getInstance("Blowfish");
+        cipher.init(Cipher.DECRYPT_MODE, key);
+        decrypted = cipher.doFinal(hexStringToByteArray(toDecrypt));
+        return new String(decrypted);
+      } catch (Exception e) {
+        e.printStackTrace();
+      }
     }
-    byte[] decrypted;
-    try {
-      SecretKeySpec key = new SecretKeySpec(init, "Blowfish");
-      Cipher cipher = Cipher.getInstance("Blowfish");
-      cipher.init(Cipher.DECRYPT_MODE, key);
-      decrypted = cipher.doFinal(hexStringToByteArray(toDecrypt));
-      return new String(decrypted);
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
-    return toDecrypt;
+    return password;
   }
 
   private static byte[] hexStringToByteArray(String s) {

http://git-wip-us.apache.org/repos/asf/geode/blob/80534501/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneClientSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneClientSecurityDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneClientSecurityDUnitTest.java
index 3e6b541..7ab3365 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneClientSecurityDUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneClientSecurityDUnitTest.java
@@ -14,8 +14,22 @@
  */
 package org.apache.geode.cache.lucene;
 
+import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME;
+import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_AUTH_INIT;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Properties;
+
 import junitparams.JUnitParamsRunner;
 import junitparams.Parameters;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.client.ClientCache;
@@ -26,22 +40,8 @@ import org.apache.geode.cache.server.CacheServer;
 import org.apache.geode.security.NotAuthorizedException;
 import org.apache.geode.security.SimpleTestSecurityManager;
 import org.apache.geode.security.templates.UserPasswordAuthInit;
-import org.apache.geode.test.dunit.SerializableRunnableIF;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-import java.io.IOException;
-import java.util.Properties;
-
-import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME;
-import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME;
-import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_AUTH_INIT;
-import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
 
 @Category({DistributedTest.class, SecurityTest.class})
 @RunWith(JUnitParamsRunner.class)
@@ -50,7 +50,7 @@ public class LuceneClientSecurityDUnitTest extends LuceneQueriesAccessorBase {
   @Test
   @Parameters(method = "getSearchIndexUserNameAndExpectedResponses")
   public void verifySearchIndexPermissions(
-      LuceneCommandsSecurityDUnitTest.UserNameAndExpectedResponse user) {
+      LuceneCommandsSecurityTest.UserNameAndExpectedResponse user) {
     // Start server
     int serverPort = dataStore1.invoke(() -> startCacheServer());
 
@@ -58,8 +58,7 @@ public class LuceneClientSecurityDUnitTest extends LuceneQueriesAccessorBase {
     accessor.invoke(() -> startClient(user.getUserName(), serverPort));
 
     // Attempt query
-    accessor.invoke(
-        () -> executeTextSearch(user.getExpectAuthorizationError(), user.getExpectedResponse()));
+    accessor.invoke(() -> executeTextSearch(user.getExpectAuthorizationError()));
   }
 
   private int startCacheServer() throws IOException {
@@ -86,8 +85,7 @@ public class LuceneClientSecurityDUnitTest extends LuceneQueriesAccessorBase {
     clientCache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create(REGION_NAME);
   }
 
-  private void executeTextSearch(boolean expectAuthorizationError, String expectedResponse)
-      throws LuceneQueryException {
+  private void executeTextSearch(boolean expectAuthorizationError) throws LuceneQueryException {
     LuceneService service = LuceneServiceProvider.get(getCache());
     LuceneQuery<Integer, TestObject> query =
         service.createLuceneQueryFactory().create(INDEX_NAME, REGION_NAME, "test", "text");
@@ -97,14 +95,12 @@ public class LuceneClientSecurityDUnitTest extends LuceneQueriesAccessorBase {
     } catch (ServerOperationException e) {
       assertTrue(e.getCause() != null && e.getCause() instanceof NotAuthorizedException);
       assertTrue(expectAuthorizationError);
-      assertTrue(e.getLocalizedMessage().contains(expectedResponse));
     }
   }
 
-  protected LuceneCommandsSecurityDUnitTest.UserNameAndExpectedResponse[] getSearchIndexUserNameAndExpectedResponses() {
-    return new LuceneCommandsSecurityDUnitTest.UserNameAndExpectedResponse[] {
-        new LuceneCommandsSecurityDUnitTest.UserNameAndExpectedResponse("nopermissions", true,
-            "nopermissions not authorized for DATA:WRITE"),
-        new LuceneCommandsSecurityDUnitTest.UserNameAndExpectedResponse("datawrite", false, null)};
+  protected LuceneCommandsSecurityTest.UserNameAndExpectedResponse[] getSearchIndexUserNameAndExpectedResponses() {
+    return new LuceneCommandsSecurityTest.UserNameAndExpectedResponse[] {
+        new LuceneCommandsSecurityTest.UserNameAndExpectedResponse("nopermissions", true),
+        new LuceneCommandsSecurityTest.UserNameAndExpectedResponse("datawrite", false)};
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/80534501/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java
deleted file mode 100644
index 7cc6709..0000000
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java
+++ /dev/null
@@ -1,291 +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.cache.lucene;
-
-import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME;
-import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME;
-import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-import junitparams.JUnitParamsRunner;
-import junitparams.Parameters;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.cache.lucene.internal.cli.LuceneCliStrings;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.result.CommandResult;
-import org.apache.geode.management.internal.cli.result.ErrorResultData;
-import org.apache.geode.management.internal.cli.result.ResultBuilder;
-import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
-import org.apache.geode.security.SimpleTestSecurityManager;
-import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.MemberVM;
-import org.apache.geode.test.junit.categories.DistributedTest;
-import org.apache.geode.test.junit.categories.SecurityTest;
-
-@Category({DistributedTest.class, SecurityTest.class})
-@RunWith(JUnitParamsRunner.class)
-public class LuceneCommandsSecurityDUnitTest {
-
-  @Rule
-  public LocatorServerStartupRule locatorServer = new LocatorServerStartupRule();
-
-  @Rule
-  public GfshShellConnectionRule gfshShell = new GfshShellConnectionRule();
-
-  private MemberVM locator;
-
-  @Before
-  public void before() throws Exception {
-    // start the locator
-    Properties props = new Properties();
-    props.setProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName());
-    this.locator = this.locatorServer.startLocatorVM(0, props);
-
-    // start the server
-    props = new Properties();
-    props.setProperty("security-username", "clusterManage");
-    props.setProperty("security-password", "clusterManage");
-    this.locatorServer.startServerVM(1, props, this.locator.getPort());
-  }
-
-  protected UserNameAndExpectedResponse[] getCreateIndexUserNameAndExpectedResponses() {
-    return new UserNameAndExpectedResponse[] {
-        new UserNameAndExpectedResponse("noPermissions", true,
-            "Unauthorized. Reason : noPermissions not authorized for CLUSTER:MANAGE:QUERY"),
-        new UserNameAndExpectedResponse("clusterManageQuery", false,
-            "Successfully created lucene index")};
-  }
-
-  @Test
-  @Parameters(method = "getCreateIndexUserNameAndExpectedResponses")
-  public void verifyCreateIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
-    // Connect gfsh
-    this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
-        GfshShellConnectionRule.PortType.locator, user.getUserName(), user.getUserName());
-
-    // Attempt to create lucene index
-    CommandResult result = this.gfshShell.executeCommand(getCreateIndexCommand());
-
-    // Verify result
-    verifyResult(user, result);
-  }
-
-  protected UserNameAndExpectedResponse[] getSearchIndexUserNameAndExpectedResponses() {
-    return new UserNameAndExpectedResponse[] {
-        new UserNameAndExpectedResponse("noPermissions", true,
-            "Unauthorized. Reason : noPermissions not authorized for DATA:READ:region"),
-        new UserNameAndExpectedResponse("dataRead", false, "No results")};
-  }
-
-  @Test
-  @Parameters(method = "getSearchIndexUserNameAndExpectedResponses")
-  public void verifySearchIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
-    // Create index and region
-    createIndexAndRegion();
-
-    // Connect gfsh
-    this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
-        GfshShellConnectionRule.PortType.locator, user.getUserName(), user.getUserName());
-
-    // Attempt to search lucene index
-    CommandResult result = this.gfshShell.executeCommand(getSearchIndexCommand());
-
-    // Verify result
-    verifyResult(user, result);
-  }
-
-  protected UserNameAndExpectedResponse[] getListIndexesUserNameAndExpectedResponses() {
-    return new UserNameAndExpectedResponse[] {
-        new UserNameAndExpectedResponse("noPermissions", true,
-            "Unauthorized. Reason : noPermissions not authorized for CLUSTER:READ:QUERY"),
-        new UserNameAndExpectedResponse("clusterReadQuery", false, "Index Name")};
-  }
-
-  @Test
-  @Parameters(method = "getListIndexesUserNameAndExpectedResponses")
-  public void verifyListIndexesPermissions(UserNameAndExpectedResponse user) throws Exception {
-    // Create index and region
-    createIndexAndRegion();
-
-    // Connect gfsh
-    this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
-        GfshShellConnectionRule.PortType.locator, user.getUserName(), user.getUserName());
-
-    // Attempt to search lucene index
-    CommandResult result = this.gfshShell.executeCommand(getListIndexesCommand());
-
-    // Verify result
-    verifyResult(user, result);
-  }
-
-  protected UserNameAndExpectedResponse[] getDescribeIndexUserNameAndExpectedResponses() {
-    return new UserNameAndExpectedResponse[] {
-        new UserNameAndExpectedResponse("noPermissions", true,
-            "Unauthorized. Reason : noPermissions not authorized for CLUSTER:READ:QUERY"),
-        new UserNameAndExpectedResponse("clusterReadQuery", false, "Index Name")};
-  }
-
-  @Test
-  @Parameters(method = "getDescribeIndexUserNameAndExpectedResponses")
-  public void verifyDescribeIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
-    // Create index and region
-    createIndexAndRegion();
-
-    // Connect gfsh
-    this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
-        GfshShellConnectionRule.PortType.locator, user.getUserName(), user.getUserName());
-
-    // Attempt to search lucene index
-    CommandResult result = this.gfshShell.executeCommand(getDescribeIndexCommand());
-
-    // Verify result
-    verifyResult(user, result);
-  }
-
-  protected UserNameAndExpectedResponse[] getDestroyIndexUserNameAndExpectedResponses() {
-    return new UserNameAndExpectedResponse[] {
-        new UserNameAndExpectedResponse("noPermissions", true,
-            "Unauthorized. Reason : noPermissions not authorized for CLUSTER:MANAGE:QUERY"),
-        new UserNameAndExpectedResponse("clusterManageQuery", false,
-            "Successfully destroyed lucene index")};
-  }
-
-  @Test
-  @Parameters(method = "getDestroyIndexUserNameAndExpectedResponses")
-  public void verifyDestroyIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
-    // Create index and region
-    createIndexAndRegion();
-
-    // Connect gfsh
-    this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
-        GfshShellConnectionRule.PortType.locator, user.getUserName(), user.getUserName());
-
-    // Attempt to search lucene index
-    CommandResult result = this.gfshShell.executeCommand(getDestroyIndexCommand());
-
-    // Verify result
-    verifyResult(user, result);
-  }
-
-  private void createIndexAndRegion() throws Exception {
-    // Connect gfsh to locator with permissions necessary to create an index and region
-    this.gfshShell.secureConnectAndVerify(this.locator.getPort(),
-        GfshShellConnectionRule.PortType.locator, "cluster,data", "cluster,data");
-
-    // Create lucene index
-    this.gfshShell.executeAndVerifyCommand(getCreateIndexCommand());
-
-    // Create region
-    this.gfshShell.executeAndVerifyCommand(getCreateRegionCommand());
-
-    // Disconnect gfsh
-    this.gfshShell.disconnect();
-  }
-
-  private void verifyResult(UserNameAndExpectedResponse user, CommandResult result) {
-    if (user.getExpectAuthorizationError()) {
-      assertTrue(result.getResultData() instanceof ErrorResultData);
-      assertEquals(ResultBuilder.ERRORCODE_UNAUTHORIZED,
-          ((ErrorResultData) result.getResultData()).getErrorCode());
-    } else {
-      assertEquals(Result.Status.OK, result.getStatus());
-    }
-    assertTrue(this.gfshShell.getGfshOutput().contains(user.getExpectedResponse()));
-  }
-
-  private String getCreateIndexCommand() {
-    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
-    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
-    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
-    csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1");
-    return csb.toString();
-  }
-
-  private String getCreateRegionCommand() {
-    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_REGION);
-    csb.addOption(CliStrings.CREATE_REGION__REGION, REGION_NAME);
-    csb.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT,
-        RegionShortcut.PARTITION_REDUNDANT.name());
-    return csb.toString();
-  }
-
-  private String getSearchIndexCommand() {
-    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_SEARCH_INDEX);
-    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
-    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
-    csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING, "field1:value1");
-    csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field1");
-    return csb.toString();
-  }
-
-  private String getListIndexesCommand() {
-    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_LIST_INDEX);
-    return csb.toString();
-  }
-
-  private String getDescribeIndexCommand() {
-    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESCRIBE_INDEX);
-    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
-    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
-    return csb.toString();
-  }
-
-  private String getDestroyIndexCommand() {
-    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESTROY_INDEX);
-    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
-    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
-    return csb.toString();
-  }
-
-  public static class UserNameAndExpectedResponse implements Serializable {
-
-    private final String userName;
-
-    private final boolean expectAuthorizationError;
-
-    private final String expectedResponse;
-
-    public UserNameAndExpectedResponse(String userName, boolean expectAuthorizationError,
-        String expectedResponse) {
-      this.userName = userName;
-      this.expectAuthorizationError = expectAuthorizationError;
-      this.expectedResponse = expectedResponse;
-    }
-
-    public String getUserName() {
-      return this.userName;
-    }
-
-    public boolean getExpectAuthorizationError() {
-      return this.expectAuthorizationError;
-    }
-
-    public String getExpectedResponse() {
-      return this.expectedResponse;
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/80534501/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityTest.java
new file mode 100644
index 0000000..c195611
--- /dev/null
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityTest.java
@@ -0,0 +1,263 @@
+/*
+ * 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.cache.lucene;
+
+import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME;
+import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.Serializable;
+
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
+import org.junit.After;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.cache.lucene.internal.cli.LuceneCliStrings;
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.CommandResult;
+import org.apache.geode.management.internal.cli.result.ErrorResultData;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
+import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
+import org.apache.geode.security.SimpleTestSecurityManager;
+import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.geode.test.junit.categories.SecurityTest;
+
+@Category({IntegrationTest.class, SecurityTest.class})
+@RunWith(JUnitParamsRunner.class)
+public class LuceneCommandsSecurityTest {
+
+  @ClassRule
+  public static ServerStarterRule server = new ServerStarterRule()
+      .withSecurityManager(SimpleTestSecurityManager.class).withJMXManager().withAutoStart();
+
+  @ClassRule
+  public static GfshShellConnectionRule gfshShell = new GfshShellConnectionRule();
+
+  @After
+  public void after() throws Exception {
+    gfshShell.disconnect();
+  }
+
+
+  protected UserNameAndExpectedResponse[] getCreateIndexUserNameAndExpectedResponses() {
+    return new UserNameAndExpectedResponse[] {
+        new UserNameAndExpectedResponse("noPermissions", true),
+        new UserNameAndExpectedResponse("clusterManageQuery,clusterWriteDisk", false)};
+  }
+
+  @Test
+  @Parameters(method = "getCreateIndexUserNameAndExpectedResponses")
+  public void verifyCreateIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
+    // Connect gfsh
+    this.gfshShell.secureConnectAndVerify(this.server.getJmxPort(),
+        GfshShellConnectionRule.PortType.jmxManger, user.getUserName(), user.getUserName());
+
+    // Attempt to create lucene index
+    CommandResult result = this.gfshShell.executeCommand(getCreateIndexCommand());
+
+    // Verify result
+    verifyResult(user, result);
+  }
+
+  protected UserNameAndExpectedResponse[] getSearchIndexUserNameAndExpectedResponses() {
+    return new UserNameAndExpectedResponse[] {
+        new UserNameAndExpectedResponse("noPermissions", true),
+        new UserNameAndExpectedResponse("dataRead", false)};
+  }
+
+  @Test
+  @Parameters(method = "getSearchIndexUserNameAndExpectedResponses")
+  public void verifySearchIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
+    // Create index and region
+    // createIndexAndRegion();
+
+    // Connect gfsh
+    this.gfshShell.secureConnectAndVerify(this.server.getJmxPort(),
+        GfshShellConnectionRule.PortType.jmxManger, user.getUserName(), user.getUserName());
+
+    // Attempt to search lucene index
+    CommandResult result = this.gfshShell.executeCommand(getSearchIndexCommand());
+
+    // Verify result
+    verifyResult(user, result);
+  }
+
+  protected UserNameAndExpectedResponse[] getListIndexesUserNameAndExpectedResponses() {
+    return new UserNameAndExpectedResponse[] {
+        new UserNameAndExpectedResponse("noPermissions", true),
+        new UserNameAndExpectedResponse("clusterReadQuery", false)};
+  }
+
+  @Test
+  @Parameters(method = "getListIndexesUserNameAndExpectedResponses")
+  public void verifyListIndexesPermissions(UserNameAndExpectedResponse user) throws Exception {
+    // Create index and region
+    // createIndexAndRegion();
+
+    // Connect gfsh
+    this.gfshShell.secureConnectAndVerify(this.server.getJmxPort(),
+        GfshShellConnectionRule.PortType.jmxManger, user.getUserName(), user.getUserName());
+
+    // Attempt to search lucene index
+    CommandResult result = this.gfshShell.executeCommand(getListIndexesCommand());
+
+    // Verify result
+    verifyResult(user, result);
+  }
+
+  protected UserNameAndExpectedResponse[] getDescribeIndexUserNameAndExpectedResponses() {
+    return new UserNameAndExpectedResponse[] {
+        new UserNameAndExpectedResponse("noPermissions", true),
+        new UserNameAndExpectedResponse("clusterReadQuery", false)};
+  }
+
+  @Test
+  @Parameters(method = "getDescribeIndexUserNameAndExpectedResponses")
+  public void verifyDescribeIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
+    // Create index and region
+    // createIndexAndRegion();
+
+    // Connect gfsh
+    this.gfshShell.secureConnectAndVerify(this.server.getJmxPort(),
+        GfshShellConnectionRule.PortType.jmxManger, user.getUserName(), user.getUserName());
+
+    // Attempt to search lucene index
+    CommandResult result = this.gfshShell.executeCommand(getDescribeIndexCommand());
+
+    // Verify result
+    verifyResult(user, result);
+  }
+
+  protected UserNameAndExpectedResponse[] getDestroyIndexUserNameAndExpectedResponses() {
+    return new UserNameAndExpectedResponse[] {
+        new UserNameAndExpectedResponse("noPermissions", true),
+        new UserNameAndExpectedResponse("clusterManageQuery", false)};
+  }
+
+  @Test
+  @Parameters(method = "getDestroyIndexUserNameAndExpectedResponses")
+  public void verifyDestroyIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
+    // Create index and region
+    // createIndexAndRegion();
+
+    // Connect gfsh
+    this.gfshShell.secureConnectAndVerify(this.server.getJmxPort(),
+        GfshShellConnectionRule.PortType.jmxManger, user.getUserName(), user.getUserName());
+
+    // Attempt to search lucene index
+    CommandResult result = this.gfshShell.executeCommand(getDestroyIndexCommand());
+
+    // Verify result
+    verifyResult(user, result);
+  }
+
+  private void createIndexAndRegion() throws Exception {
+    // Connect gfsh to locator with permissions necessary to create an index and region
+    this.gfshShell.secureConnectAndVerify(this.server.getJmxPort(),
+        GfshShellConnectionRule.PortType.jmxManger, "cluster,data", "cluster,data");
+
+    // Create lucene index
+    this.gfshShell.executeAndVerifyCommand(getCreateIndexCommand());
+
+    // Create region
+    this.gfshShell.executeAndVerifyCommand(getCreateRegionCommand());
+
+    // Disconnect gfsh
+    this.gfshShell.disconnect();
+  }
+
+  private void verifyResult(UserNameAndExpectedResponse user, CommandResult result) {
+    if (user.getExpectAuthorizationError()) {
+      assertTrue(result.getResultData() instanceof ErrorResultData);
+      assertEquals(ResultBuilder.ERRORCODE_UNAUTHORIZED,
+          ((ErrorResultData) result.getResultData()).getErrorCode());
+    } else {
+      assertEquals(Result.Status.OK, result.getStatus());
+    }
+  }
+
+  private String getCreateIndexCommand() {
+    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
+    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
+    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
+    csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1");
+    return csb.toString();
+  }
+
+  private String getCreateRegionCommand() {
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_REGION);
+    csb.addOption(CliStrings.CREATE_REGION__REGION, REGION_NAME);
+    csb.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT,
+        RegionShortcut.PARTITION_REDUNDANT.name());
+    return csb.toString();
+  }
+
+  private String getSearchIndexCommand() {
+    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_SEARCH_INDEX);
+    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
+    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
+    csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING, "field1:value1");
+    csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field1");
+    return csb.toString();
+  }
+
+  private String getListIndexesCommand() {
+    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_LIST_INDEX);
+    return csb.toString();
+  }
+
+  private String getDescribeIndexCommand() {
+    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESCRIBE_INDEX);
+    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
+    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
+    return csb.toString();
+  }
+
+  private String getDestroyIndexCommand() {
+    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESTROY_INDEX);
+    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
+    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
+    return csb.toString();
+  }
+
+  public static class UserNameAndExpectedResponse implements Serializable {
+
+    private final String userName;
+
+    private final boolean expectAuthorizationError;
+
+    public UserNameAndExpectedResponse(String userName, boolean expectAuthorizationError) {
+      this.userName = userName;
+      this.expectAuthorizationError = expectAuthorizationError;
+    }
+
+    public String getUserName() {
+      return this.userName;
+    }
+
+    public boolean getExpectAuthorizationError() {
+      return this.expectAuthorizationError;
+    }
+  }
+}


[04/46] geode git commit: GEODE-3071: Pull config of docker volumes into top level script so that they can be overridden

Posted by zh...@apache.org.
GEODE-3071: Pull config of docker volumes into top level script so that they can be overridden


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

Branch: refs/heads/feature/GEM-1483
Commit: 07e8986e3deb722c0beea380eac00a18c86844aa
Parents: b26fa51
Author: Jens Deppe <jd...@pivotal.io>
Authored: Mon Jun 19 07:42:57 2017 -0700
Committer: Jens Deppe <jd...@pivotal.io>
Committed: Mon Jun 19 07:48:27 2017 -0700

----------------------------------------------------------------------
 build.gradle         | 5 +++++
 gradle/docker.gradle | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/07e8986e/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 57372b3..4feb879 100755
--- a/build.gradle
+++ b/build.gradle
@@ -74,6 +74,11 @@ if (name == 'geode') {
   ext.scriptDir = 'gradle'
 }
 
+if (project.hasProperty('parallelDunit')) {
+  def pwd = System.getenv('PWD')
+  ext.dunitDockerVolumes = ["${pwd}":pwd]
+}
+
 apply from: "${scriptDir}/utilities.gradle"
 apply from: "${scriptDir}/java.gradle"
 apply from: "${scriptDir}/dependency-resolution.gradle"

http://git-wip-us.apache.org/repos/asf/geode/blob/07e8986e/gradle/docker.gradle
----------------------------------------------------------------------
diff --git a/gradle/docker.gradle b/gradle/docker.gradle
index b67c073..7971974 100644
--- a/gradle/docker.gradle
+++ b/gradle/docker.gradle
@@ -47,11 +47,11 @@ def dockerConfig = {
 
     // volumes mounted to the containers
     // in a form: host_dir : container_dir
-    def pwd = System.getenv('PWD')
     def gradleHome = System.getenv('GRADLE_USER_HOME') ?: "${System.getenv('HOME')}/.gradle"
     volumes = ["${gradleHome}":gradleHome]
 
-    volumes << ["${pwd}":pwd]
+    // Add volumes configured by top-level build script
+    volumes << project.dunitDockerVolumes
 
     // specify the user for starting Gradle test worker within the container.
     user = dunitDockerUser


[20/46] geode git commit: GEODE-3101: Release local locks held by the JTA beforeCompletion() in client when the JTA failed on the server.

Posted by zh...@apache.org.
GEODE-3101: Release local locks held by the JTA beforeCompletion() in client  when the JTA failed on the server.

          Also added a unit test would fail without the fix.


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

Branch: refs/heads/feature/GEM-1483
Commit: b7f5391d983cda4d95dc34a21aeb414a3c0a14c2
Parents: 822946b
Author: eshu <es...@pivotal.io>
Authored: Wed Jun 21 15:41:25 2017 -0700
Committer: eshu <es...@pivotal.io>
Committed: Wed Jun 21 15:41:25 2017 -0700

----------------------------------------------------------------------
 .../internal/cache/tx/ClientTXStateStub.java    |  10 +-
 .../internal/jta/ClientServerJTADUnitTest.java  | 143 +++++++++++++++++++
 2 files changed, 151 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/b7f5391d/geode-core/src/main/java/org/apache/geode/internal/cache/tx/ClientTXStateStub.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tx/ClientTXStateStub.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tx/ClientTXStateStub.java
index ded789e..ab5701c 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tx/ClientTXStateStub.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tx/ClientTXStateStub.java
@@ -21,7 +21,7 @@ import java.util.List;
 import javax.transaction.Status;
 
 import org.apache.logging.log4j.Logger;
-
+import org.apache.geode.GemFireException;
 import org.apache.geode.cache.CommitConflictException;
 import org.apache.geode.cache.TransactionDataNodeHasDepartedException;
 import org.apache.geode.cache.TransactionException;
@@ -237,7 +237,13 @@ public class ClientTXStateStub extends TXStateStub {
   @Override
   public void beforeCompletion() {
     obtainLocalLocks();
-    this.firstProxy.beforeCompletion(proxy.getTxId().getUniqId());
+    try {
+      this.firstProxy.beforeCompletion(proxy.getTxId().getUniqId());
+    } catch (GemFireException e) {
+      this.lockReq.releaseLocal();
+      this.firstProxy.getPool().releaseServerAffinity();
+      throw e;
+    }
   }
 
   public InternalDistributedMember getOriginatingMember() {

http://git-wip-us.apache.org/repos/asf/geode/blob/b7f5391d/geode-core/src/test/java/org/apache/geode/internal/jta/ClientServerJTADUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/jta/ClientServerJTADUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/jta/ClientServerJTADUnitTest.java
new file mode 100644
index 0000000..51ef44a
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/jta/ClientServerJTADUnitTest.java
@@ -0,0 +1,143 @@
+/*
+ * 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.internal.jta;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import javax.transaction.Status;
+
+import org.apache.geode.GemFireException;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.cache.client.ClientCache;
+import org.apache.geode.cache.client.ClientCacheFactory;
+import org.apache.geode.cache.client.ClientRegionShortcut;
+import org.apache.geode.cache.server.CacheServer;
+import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.internal.cache.TXManagerImpl;
+import org.apache.geode.internal.cache.TXStateProxyImpl;
+import org.apache.geode.internal.cache.tx.ClientTXStateStub;
+import org.apache.geode.test.dunit.Assert;
+import org.apache.geode.test.dunit.Host;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.awaitility.Awaitility;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category({DistributedTest.class})
+public class ClientServerJTADUnitTest extends JUnit4CacheTestCase {
+  private String key = "key";
+  private String value = "value";
+  private String newValue = "newValue";
+
+  @Test
+  public void testClientTXStateStubBeforeCompletion() throws Exception {
+    final Host host = Host.getHost(0);
+    final VM server = host.getVM(0);
+    final VM client = host.getVM(1);
+    final String regionName = getUniqueName();
+    getBlackboard().initBlackboard();
+    final Properties properties = getDistributedSystemProperties();
+
+    final int port = server.invoke("create cache", () -> {
+      Cache cache = getCache(properties);
+      CacheServer cacheServer = createCacheServer(cache);
+      Region region = cache.createRegionFactory(RegionShortcut.REPLICATE).create(regionName);
+      region.put(key, value);
+
+      return cacheServer.getPort();
+    });
+
+    client.invoke(() -> createClientRegion(host, port, regionName));
+
+    createClientRegion(host, port, regionName);
+
+    Region region = getCache().getRegion(regionName);
+    assertTrue(region.get(key).equals(value));
+
+    String first = "one";
+    String second = "two";
+
+    client.invokeAsync(() -> commitTxWithBeforeCompletion(regionName, true, first, second));
+
+    getBlackboard().waitForGate(first, 30, TimeUnit.SECONDS);
+    TXManagerImpl mgr = (TXManagerImpl) getCache().getCacheTransactionManager();
+    mgr.begin();
+    region.put(key, newValue);
+    TXStateProxyImpl tx = (TXStateProxyImpl) mgr.internalSuspend();
+    ClientTXStateStub txStub = (ClientTXStateStub) tx.getRealDeal(null, null);
+    mgr.internalResume(tx);
+    try {
+      txStub.beforeCompletion();
+      fail("expected to get CommitConflictException");
+    } catch (GemFireException e) {
+      // expected commit conflict exception thrown from server
+      mgr.setTXState(null);
+      getBlackboard().signalGate(second);
+    }
+
+    Awaitility.await().pollInterval(10, TimeUnit.MILLISECONDS).pollDelay(10, TimeUnit.MILLISECONDS)
+        .atMost(30, TimeUnit.SECONDS).until(() -> region.get(key).equals(newValue));
+
+    try {
+      commitTxWithBeforeCompletion(regionName, false, first, second);
+    } catch (Exception e) {
+      Assert.fail("got unexpected exception", e);
+    }
+  }
+
+  private CacheServer createCacheServer(Cache cache) {
+    CacheServer server = cache.addCacheServer();
+    server.setPort(AvailablePortHelper.getRandomAvailableTCPPort());
+    try {
+      server.start();
+    } catch (IOException e) {
+      Assert.fail("got exception", e);
+    }
+    return server;
+  }
+
+  private void createClientRegion(final Host host, final int port0, String regionName) {
+    ClientCacheFactory cf = new ClientCacheFactory();
+    cf.addPoolServer(host.getHostName(), port0);
+    ClientCache cache = getClientCache(cf);
+    cache.createClientRegionFactory(ClientRegionShortcut.PROXY).create(regionName);
+  }
+
+  private void commitTxWithBeforeCompletion(String regionName, boolean withWait, String first,
+      String second) throws TimeoutException, InterruptedException {
+    Region region = getCache().getRegion(regionName);
+    TXManagerImpl mgr = (TXManagerImpl) getCache().getCacheTransactionManager();
+    mgr.begin();
+    region.put(key, newValue);
+    TXStateProxyImpl tx = (TXStateProxyImpl) mgr.internalSuspend();
+    ClientTXStateStub txStub = (ClientTXStateStub) tx.getRealDeal(null, null);
+    mgr.internalResume(tx);
+    txStub.beforeCompletion();
+    if (withWait) {
+      getBlackboard().signalGate(first);
+      getBlackboard().waitForGate(second, 30, TimeUnit.SECONDS);
+    }
+    txStub.afterCompletion(Status.STATUS_COMMITTED);
+  }
+}


[40/46] geode git commit: GEODE-2995: more review feedback and spotlessApply

Posted by zh...@apache.org.
GEODE-2995: more review feedback and spotlessApply

Signed-off-by: Brian Rowe <br...@pivotal.io>


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

Branch: refs/heads/feature/GEM-1483
Commit: 0de1d97ea229ec43203437f58971c44fe37cef62
Parents: 31f4de0
Author: Galen O'Sullivan <go...@pivotal.io>
Authored: Tue Jun 20 16:58:51 2017 -0700
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Mon Jun 26 09:26:22 2017 -0700

----------------------------------------------------------------------
 .../protocol/operations/OperationHandler.java   | 20 ++++++++++++------
 ...rationHandlerAlreadyRegisteredException.java |  3 ++-
 .../protocol/protobuf/ProtobufOpsProcessor.java | 22 ++++++++++----------
 .../protobuf/ProtobufStreamProcessor.java       |  7 +++++--
 .../protocol/serializer/ProtocolSerializer.java |  1 +
 .../serialization/SerializationService.java     |  7 ++++++-
 .../geode/serialization/SerializationType.java  |  3 +++
 .../apache/geode/serialization/TypeCodec.java   | 10 +++++++++
 .../exception/TypeEncodingException.java        | 21 +++++++++++++++++++
 .../UnsupportedEncodingTypeException.java       |  2 +-
 .../CodecAlreadyRegisteredForTypeException.java |  3 ++-
 .../CodecNotRegisteredForTypeException.java     |  4 +++-
 .../geode/client/protocol/IntegrationTest.java  |  3 +--
 .../protobuf/ProtobufOpsProcessorTest.java      | 10 ++++-----
 .../ProtobufProtocolSerializerJUnitTest.java    |  2 +-
 15 files changed, 86 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/0de1d97e/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/OperationHandler.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/OperationHandler.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/OperationHandler.java
index 8eab146..7683e3b 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/OperationHandler.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/OperationHandler.java
@@ -15,23 +15,31 @@
 package org.apache.geode.protocol.operations;
 
 import org.apache.geode.cache.Cache;
-import org.apache.geode.protocol.protobuf.ProtobufOpsProcessor;
 import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry;
+import org.apache.geode.protocol.protobuf.ProtobufOpsProcessor;
 import org.apache.geode.serialization.SerializationService;
-import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
-import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+import org.apache.geode.serialization.exception.TypeEncodingException;
 
 /**
- * This interface is implemented by a object capable of handling request types 'Req' and returning an a response of type 'Resp'
+ * This interface is implemented by a object capable of handling request types 'Req' and returning
+ * an a response of type 'Resp'
  *
  * See {@link ProtobufOpsProcessor}
  */
 public interface OperationHandler<Req, Resp> {
+  /**
+   * Decode the message, deserialize contained values using the serialization service, do the work
+   * indicated on the provided cache, and return a response.
+   * 
+   * @throws TypeEncodingException if a problem occurs decoding an encoded value contained in the
+   *         request.
+   */
   Resp process(SerializationService serializationService, Req request, Cache cache)
-      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException;
+      throws TypeEncodingException;
 
   /**
-   * @return the magic number used for registering the operation type with the {@link OperationsHandlerRegistry}.
+   * @return the magic number used for registering the operation type with the
+   *         {@link OperationsHandlerRegistry}.
    */
   int getOperationCode();
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/0de1d97e/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerAlreadyRegisteredException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerAlreadyRegisteredException.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerAlreadyRegisteredException.java
index 519698d..18475d8 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerAlreadyRegisteredException.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerAlreadyRegisteredException.java
@@ -15,7 +15,8 @@
 package org.apache.geode.protocol.operations.registry.exception;
 
 /**
- * Indicates that an operation handler is attempting to register for an already handled operation type.
+ * Indicates that an operation handler is attempting to register for an already handled operation
+ * type.
  */
 public class OperationHandlerAlreadyRegisteredException extends Exception {
   public OperationHandlerAlreadyRegisteredException(String message) {

http://git-wip-us.apache.org/repos/asf/geode/blob/0de1d97e/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessor.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessor.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessor.java
index c572d80..d426149 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessor.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessor.java
@@ -20,37 +20,37 @@ import org.apache.geode.protocol.operations.OperationHandler;
 import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry;
 import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException;
 import org.apache.geode.serialization.SerializationService;
-import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
-import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+import org.apache.geode.serialization.exception.TypeEncodingException;
 
 /**
- * This handles protobuf requests by determining the operation type of the request and dispatching it to the appropriate handler.
+ * This handles protobuf requests by determining the operation type of the request and dispatching
+ * it to the appropriate handler.
  */
 public class ProtobufOpsProcessor {
   private final OperationsHandlerRegistry opsHandlerRegistry;
   private final SerializationService serializationService;
 
   public ProtobufOpsProcessor(OperationsHandlerRegistry opsHandlerRegistry,
-                              SerializationService serializationService) {
+      SerializationService serializationService) {
     this.opsHandlerRegistry = opsHandlerRegistry;
     this.serializationService = serializationService;
   }
 
   public ClientProtocol.Response process(ClientProtocol.Request request, Cache cache)
-    throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException,
-    OperationHandlerNotRegisteredException, InvalidProtocolMessageException {
+      throws TypeEncodingException, OperationHandlerNotRegisteredException,
+      InvalidProtocolMessageException {
     OperationHandler opsHandler = opsHandlerRegistry
-      .getOperationHandlerForOperationId(request.getRequestAPICase().getNumber());
+        .getOperationHandlerForOperationId(request.getRequestAPICase().getNumber());
 
-    Object responseMessage = opsHandler.process(serializationService,
-        getRequestForOperationTypeID(request), cache);
+    Object responseMessage =
+        opsHandler.process(serializationService, getRequestForOperationTypeID(request), cache);
     return ClientProtocol.Response.newBuilder()
         .setGetResponse((RegionAPI.GetResponse) responseMessage).build();
   }
 
   // package visibility for testing
   static Object getRequestForOperationTypeID(ClientProtocol.Request request)
-    throws InvalidProtocolMessageException {
+      throws InvalidProtocolMessageException {
     switch (request.getRequestAPICase()) {
       case PUTREQUEST:
         return request.getPutRequest();
@@ -60,7 +60,7 @@ public class ProtobufOpsProcessor {
         return request.getPutAllRequest();
       default:
         throw new InvalidProtocolMessageException(
-          "Unknown request type: " + request.getRequestAPICase().getNumber());
+            "Unknown request type: " + request.getRequestAPICase().getNumber());
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/0de1d97e/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufStreamProcessor.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufStreamProcessor.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufStreamProcessor.java
index 41a3c40..1dcb61c 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufStreamProcessor.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufStreamProcessor.java
@@ -20,6 +20,7 @@ import org.apache.geode.protocol.protobuf.serializer.ProtobufProtocolSerializer;
 import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry;
 import org.apache.geode.protocol.operations.registry.exception.OperationHandlerAlreadyRegisteredException;
 import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException;
+import org.apache.geode.serialization.exception.TypeEncodingException;
 import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
 import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
 import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
@@ -29,7 +30,9 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 /**
- * This object handles an incoming stream containing protobuf messages. It parses the protobuf messages, hands the requests to an appropriate handler, wraps the response in a protobuf message, and then pushes it to the output stream.
+ * This object handles an incoming stream containing protobuf messages. It parses the protobuf
+ * messages, hands the requests to an appropriate handler, wraps the response in a protobuf message,
+ * and then pushes it to the output stream.
  */
 public class ProtobufStreamProcessor {
   ProtobufProtocolSerializer protobufProtocolSerializer;
@@ -47,7 +50,7 @@ public class ProtobufStreamProcessor {
 
   public void processOneMessage(InputStream inputStream, OutputStream outputStream, Cache cache)
       throws InvalidProtocolMessageException, OperationHandlerNotRegisteredException,
-      UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException, IOException {
+      TypeEncodingException, IOException {
     ClientProtocol.Message message = protobufProtocolSerializer.deserialize(inputStream);
 
     ClientProtocol.Request request = message.getRequest();

http://git-wip-us.apache.org/repos/asf/geode/blob/0de1d97e/geode-protobuf/src/main/java/org/apache/geode/protocol/serializer/ProtocolSerializer.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/serializer/ProtocolSerializer.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/serializer/ProtocolSerializer.java
index 7191d87..46e491f 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/serializer/ProtocolSerializer.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/serializer/ProtocolSerializer.java
@@ -22,6 +22,7 @@ import java.io.OutputStream;
 
 /**
  * This interface is used to translate between binary data and protocol specific messages.
+ * 
  * @param <T> The message type of the protocol.
  */
 public interface ProtocolSerializer<T> {

http://git-wip-us.apache.org/repos/asf/geode/blob/0de1d97e/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationService.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationService.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationService.java
index 623a7bd..cdeb170 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationService.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationService.java
@@ -17,8 +17,13 @@ package org.apache.geode.serialization;
 import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
 import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
 
+/**
+ * This interface takes an protocol specific encodingTypeValue enum and converts between objects and
+ * bytes using the encodingTypeValue to decide what encoding type to use.
+ *
+ * @param <T> the enumeration of types known to a particular protocol
+ */
 public interface SerializationService<T> {
-
   Object decode(T encodingTypeValue, byte[] value)
       throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException;
 

http://git-wip-us.apache.org/repos/asf/geode/blob/0de1d97e/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java
index 4ea4422..91466a1 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java
@@ -16,6 +16,9 @@ package org.apache.geode.serialization;
 
 import org.apache.geode.pdx.PdxInstance;
 
+/**
+ * Enumerates the serialization types currently available to wire protocols.
+ */
 public enum SerializationType {
   STRING(String.class),
   BINARY(byte[].class),

http://git-wip-us.apache.org/repos/asf/geode/blob/0de1d97e/geode-protobuf/src/main/java/org/apache/geode/serialization/TypeCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/TypeCodec.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/TypeCodec.java
index f2c7f90..8506a53 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/TypeCodec.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/TypeCodec.java
@@ -14,10 +14,20 @@
  */
 package org.apache.geode.serialization;
 
+/**
+ * This interface converts a particular type to and from its binary representation.
+ *
+ * NOTE: it is expected that T will be one of the serialization types in @{@link SerializationType}.
+ *
+ * @param <T> the type this codec knows how to convert
+ */
 public interface TypeCodec<T> {
   T decode(byte[] incoming);
 
   byte[] encode(T incoming);
 
+  /**
+   * @return the SerializationType corresponding to T
+   */
   SerializationType getSerializationType();
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/0de1d97e/geode-protobuf/src/main/java/org/apache/geode/serialization/exception/TypeEncodingException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/exception/TypeEncodingException.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/exception/TypeEncodingException.java
new file mode 100644
index 0000000..f3145a7
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/exception/TypeEncodingException.java
@@ -0,0 +1,21 @@
+/*
+ * 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.serialization.exception;
+
+public class TypeEncodingException extends Exception {
+  public TypeEncodingException(String message) {
+    super(message);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/0de1d97e/geode-protobuf/src/main/java/org/apache/geode/serialization/exception/UnsupportedEncodingTypeException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/exception/UnsupportedEncodingTypeException.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/exception/UnsupportedEncodingTypeException.java
index 6d2a032..c577e76 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/exception/UnsupportedEncodingTypeException.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/exception/UnsupportedEncodingTypeException.java
@@ -17,7 +17,7 @@ package org.apache.geode.serialization.exception;
 /**
  * This indicates an encoding type that we don't know how to handle.
  */
-public class UnsupportedEncodingTypeException extends Exception {
+public class UnsupportedEncodingTypeException extends TypeEncodingException {
   public UnsupportedEncodingTypeException(String message) {
     super(message);
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/0de1d97e/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecAlreadyRegisteredForTypeException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecAlreadyRegisteredForTypeException.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecAlreadyRegisteredForTypeException.java
index 7e73ba9..66ae850 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecAlreadyRegisteredForTypeException.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecAlreadyRegisteredForTypeException.java
@@ -15,7 +15,8 @@
 package org.apache.geode.serialization.registry.exception;
 
 /**
- * This indicates that we're attempting to register a codec for a type which we already have a handler for.
+ * This indicates that we're attempting to register a codec for a type which we already have a
+ * handler for.
  */
 public class CodecAlreadyRegisteredForTypeException extends Exception {
   public CodecAlreadyRegisteredForTypeException(String message) {

http://git-wip-us.apache.org/repos/asf/geode/blob/0de1d97e/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecNotRegisteredForTypeException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecNotRegisteredForTypeException.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecNotRegisteredForTypeException.java
index 58cb691..5c923a5 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecNotRegisteredForTypeException.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecNotRegisteredForTypeException.java
@@ -14,10 +14,12 @@
  */
 package org.apache.geode.serialization.registry.exception;
 
+import org.apache.geode.serialization.exception.TypeEncodingException;
+
 /**
  * This indicates we're attempting to handle a type for which we don't have a registered codec.
  */
-public class CodecNotRegisteredForTypeException extends Exception {
+public class CodecNotRegisteredForTypeException extends TypeEncodingException {
   public CodecNotRegisteredForTypeException(String message) {
     super(message);
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/0de1d97e/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java
index e32c711..63cde31 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java
@@ -65,8 +65,7 @@ public class IntegrationTest {
   }
 
   @Test
-  public void testGetRequestProcessed()
-      throws Exception {
+  public void testGetRequestProcessed() throws Exception {
     ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
 
     ProtobufStreamProcessor streamProcessor = new ProtobufStreamProcessor();

http://git-wip-us.apache.org/repos/asf/geode/blob/0de1d97e/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorTest.java
index 9298026..ac3d68f 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorTest.java
@@ -24,6 +24,7 @@ import org.apache.geode.protocol.operations.OperationHandler;
 import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry;
 import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException;
 import org.apache.geode.serialization.SerializationService;
+import org.apache.geode.serialization.exception.TypeEncodingException;
 import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
 import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
 import org.apache.geode.test.junit.categories.UnitTest;
@@ -34,9 +35,8 @@ import org.junit.experimental.categories.Category;
 @Category(UnitTest.class)
 public class ProtobufOpsProcessorTest {
   @Test
-  public void testOpsProcessor() throws CodecNotRegisteredForTypeException,
-    OperationHandlerNotRegisteredException, UnsupportedEncodingTypeException,
-    InvalidProtocolMessageException {
+  public void testOpsProcessor() throws TypeEncodingException,
+      OperationHandlerNotRegisteredException, InvalidProtocolMessageException {
     OperationsHandlerRegistry opsHandlerRegistryStub = mock(OperationsHandlerRegistry.class);
     OperationHandler operationHandlerStub = mock(OperationHandler.class);
     SerializationService serializationServiceStub = mock(SerializationService.class);
@@ -54,8 +54,8 @@ public class ProtobufOpsProcessorTest {
         ProtobufOpsProcessor.getRequestForOperationTypeID(messageRequest), dummyCache))
             .thenReturn(expectedResponse);
 
-    ProtobufOpsProcessor
-      processor = new ProtobufOpsProcessor(opsHandlerRegistryStub, serializationServiceStub);
+    ProtobufOpsProcessor processor =
+        new ProtobufOpsProcessor(opsHandlerRegistryStub, serializationServiceStub);
     ClientProtocol.Response response = processor.process(messageRequest, dummyCache);
     Assert.assertEquals(expectedResponse, response.getGetResponse());
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/0de1d97e/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java
index 95244d2..e1f7b5b 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java
@@ -60,7 +60,7 @@ public class ProtobufProtocolSerializerJUnitTest {
 
   @Test(expected = InvalidProtocolMessageException.class)
   public void testDeserializeInvalidByteThrowsException()
-    throws IOException, InvalidProtocolMessageException {
+      throws IOException, InvalidProtocolMessageException {
     ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
     byteArrayOutputStream.write("Some incorrect byte array".getBytes());
     InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());


[44/46] geode git commit: Add ServiceLoadingFailureException to excludedClasses.txt so tests pass.

Posted by zh...@apache.org.
Add ServiceLoadingFailureException to excludedClasses.txt so tests pass.


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

Branch: refs/heads/feature/GEM-1483
Commit: da64fc6fbccc6a148ac7bd488593881c90b092d8
Parents: db11ebc
Author: Brian Rowe <br...@pivotal.io>
Authored: Thu Jun 22 23:27:22 2017 -0700
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Mon Jun 26 09:26:23 2017 -0700

----------------------------------------------------------------------
 .../resources/org/apache/geode/codeAnalysis/excludedClasses.txt     | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/da64fc6f/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
index 6a6e0c1..c2629f1 100644
--- a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
+++ b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
@@ -7,6 +7,7 @@ org/apache/geode/distributed/LocatorLauncher$Command
 org/apache/geode/distributed/ServerLauncher
 org/apache/geode/distributed/ServerLauncher$Command
 org/apache/geode/distributed/internal/DistributionManager
+org/apache/geode/internal/cache/tier/sockets/ServiceLoadingFailureException
 org/apache/geode/internal/JarDeployer
 org/apache/geode/internal/logging/GemFireLevel
 org/apache/geode/internal/logging/LoggingThreadGroup


[24/46] geode git commit: GEODE-2919: Provide finer grained security

Posted by zh...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommandsTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommandsTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommandsTest.java
index 155b1ad..c281080 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommandsTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommandsTest.java
@@ -16,21 +16,16 @@
 package org.apache.geode.management.internal.cli.commands;
 
 
-import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
 
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
-import org.mockito.ArgumentCaptor;
 
 import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.management.DistributedSystemMXBean;
-import org.apache.geode.management.internal.cli.functions.RegionFunctionArgs;
 import org.apache.geode.test.dunit.rules.GfshParserRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 
@@ -49,17 +44,7 @@ public class CreateAlterDestroyRegionCommandsTest {
     doReturn(cache).when(spy).getCache();
     doReturn(dsMBean).when(spy).getDSMBean(cache);
 
-    parser.executeLastCommandWithInstance(spy);
-
-    ArgumentCaptor<RegionFunctionArgs> argsCaptor =
-        ArgumentCaptor.forClass(RegionFunctionArgs.class);
-
-    verify(spy).validateRegionFunctionArgs(any(), argsCaptor.capture());
-
-    RegionFunctionArgs args = argsCaptor.getValue();
-    assertThat(args.getPartitionResolver()).isEqualTo("Foo");
-
-    assertThatThrownBy(() -> spy.validateRegionFunctionArgs(cache, args))
+    assertThatThrownBy(() -> parser.executeLastCommandWithInstance(spy))
         .hasMessageContaining("Foo is an invalid Partition Resolver");
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java
index 9a1605a..1d98087 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthenticationJUnitTest.java
@@ -16,28 +16,26 @@ package org.apache.geode.management.internal.security;
 
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
 
-import org.apache.geode.management.CacheServerMXBean;
-import org.apache.geode.security.TestSecurityManager;
-import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
-import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
-import org.apache.geode.test.dunit.rules.ServerStarterRule;
-import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import org.apache.geode.management.CacheServerMXBean;
+import org.apache.geode.security.SimpleTestSecurityManager;
+import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
+import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+
 @Category(IntegrationTest.class)
 public class CacheServerMBeanAuthenticationJUnitTest {
   private CacheServerMXBean bean;
 
   @ClassRule
   public static ServerStarterRule server = new ServerStarterRule().withJMXManager()
-      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
-      .withProperty(TestSecurityManager.SECURITY_JSON,
-          "org/apache/geode/management/internal/security/cacheServer.json")
-      .withAutoStart();
+      .withProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName()).withAutoStart();
 
   @Rule
   public MBeanServerConnectionRule connectionRule =
@@ -49,7 +47,7 @@ public class CacheServerMBeanAuthenticationJUnitTest {
   }
 
   @Test
-  @ConnectionConfiguration(user = "data-admin", password = "1234567")
+  @ConnectionConfiguration(user = "data,cluster", password = "data,cluster")
   public void testAllAccess() throws Exception {
     bean.removeIndex("foo");
     bean.fetchLoadProbe();

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java
index c7c76f6..de88614 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanAuthorizationJUnitTest.java
@@ -17,6 +17,13 @@ package org.apache.geode.management.internal.security;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
+import org.assertj.core.api.SoftAssertions;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.management.CacheServerMXBean;
 import org.apache.geode.security.TestSecurityManager;
 import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
@@ -24,11 +31,6 @@ import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class CacheServerMBeanAuthorizationJUnitTest {
@@ -58,8 +60,10 @@ public class CacheServerMBeanAuthorizationJUnitTest {
         .hasMessageContaining(TestCommand.dataRead.toString());
     bean.fetchLoadProbe();
     bean.getActiveCQCount();
-    bean.stopContinuousQuery("bar");
-    bean.closeAllContinuousQuery("bar");
+    assertThatThrownBy(() -> bean.stopContinuousQuery("bar"))
+        .hasMessageContaining(TestCommand.clusterManageQuery.toString());
+    assertThatThrownBy(() -> bean.closeAllContinuousQuery("bar"))
+        .hasMessageContaining(TestCommand.clusterManageQuery.toString());
     bean.isRunning();
     bean.showClientQueueDetails("foo");
   }
@@ -88,21 +92,25 @@ public class CacheServerMBeanAuthorizationJUnitTest {
   @Test
   @ConnectionConfiguration(user = "stranger", password = "1234567")
   public void testNoAccess() throws Exception {
-    assertThatThrownBy(() -> bean.removeIndex("foo"))
+    SoftAssertions softly = new SoftAssertions();
+
+    softly.assertThatThrownBy(() -> bean.removeIndex("foo"))
         .hasMessageContaining(TestCommand.dataManage.toString());
-    assertThatThrownBy(() -> bean.executeContinuousQuery("bar"))
+    softly.assertThatThrownBy(() -> bean.executeContinuousQuery("bar"))
         .hasMessageContaining(TestCommand.dataRead.toString());
-    assertThatThrownBy(() -> bean.fetchLoadProbe())
+    softly.assertThatThrownBy(() -> bean.fetchLoadProbe())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.getActiveCQCount())
+    softly.assertThatThrownBy(() -> bean.getActiveCQCount())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.stopContinuousQuery("bar"))
-        .hasMessageContaining(TestCommand.dataManage.toString());
-    assertThatThrownBy(() -> bean.closeAllContinuousQuery("bar"))
-        .hasMessageContaining(TestCommand.dataManage.toString());
-    assertThatThrownBy(() -> bean.isRunning())
+    softly.assertThatThrownBy(() -> bean.stopContinuousQuery("bar"))
+        .hasMessageContaining(TestCommand.clusterManageQuery.toString());
+    softly.assertThatThrownBy(() -> bean.closeAllContinuousQuery("bar"))
+        .hasMessageContaining(TestCommand.clusterManageQuery.toString());
+    softly.assertThatThrownBy(() -> bean.isRunning())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.showClientQueueDetails("bar"))
+    softly.assertThatThrownBy(() -> bean.showClientQueueDetails("bar"))
         .hasMessageContaining(TestCommand.clusterRead.toString());
+
+    softly.assertAll();
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanWithShiroIniIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanWithShiroIniIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanWithShiroIniIntegrationTest.java
index 55f592e..dc1c01a 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanWithShiroIniIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerMBeanWithShiroIniIntegrationTest.java
@@ -17,17 +17,18 @@ package org.apache.geode.management.internal.security;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_SHIRO_INIT;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.management.CacheServerMXBean;
 import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
 import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class CacheServerMBeanWithShiroIniIntegrationTest {
@@ -71,9 +72,9 @@ public class CacheServerMBeanWithShiroIniIntegrationTest {
     assertThatThrownBy(() -> bean.getActiveCQCount())
         .hasMessageContaining(TestCommand.clusterRead.toString());
     assertThatThrownBy(() -> bean.stopContinuousQuery("bar"))
-        .hasMessageContaining(TestCommand.dataManage.toString());
+        .hasMessageContaining(TestCommand.clusterManageQuery.toString());
     assertThatThrownBy(() -> bean.closeAllContinuousQuery("bar"))
-        .hasMessageContaining(TestCommand.dataManage.toString());
+        .hasMessageContaining(TestCommand.clusterManageQuery.toString());
     assertThatThrownBy(() -> bean.isRunning())
         .hasMessageContaining(TestCommand.clusterRead.toString());
     assertThatThrownBy(() -> bean.showClientQueueDetails("bar"))

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/CliCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/CliCommandsSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/CliCommandsSecurityTest.java
index a66f05b..dec4703 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/CliCommandsSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/CliCommandsSecurityTest.java
@@ -15,8 +15,15 @@
 package org.apache.geode.management.internal.security;
 
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+
+import java.util.List;
+
+import org.assertj.core.api.SoftAssertions;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.management.MemberMXBean;
@@ -27,13 +34,6 @@ import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.util.List;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class CliCommandsSecurityTest {
@@ -60,22 +60,22 @@ public class CliCommandsSecurityTest {
   @Test
   @ConnectionConfiguration(user = "stranger", password = "1234567")
   public void testNoAccess() {
+    SoftAssertions softly = new SoftAssertions();
     for (TestCommand command : commands) {
       // skip query commands since query commands are only available in client shell
       if (command.getCommand().startsWith("query"))
         continue;
       LogService.getLogger().info("processing: " + command.getCommand());
       // for those commands that requires a permission, we expect an exception to be thrown
-      if (command.getPermission() != null) {
-        try {
-          String result = bean.processCommand(command.getCommand());
-          fail(command.getCommand() + " has result: " + result);
-        } catch (NotAuthorizedException e) {
-          assertTrue(e.getMessage() + " should contain " + command.getPermission(),
-              e.getMessage().contains(command.getPermission().toString()));
-        }
+      // This has the potential to become flaky for commands with more than one permission.
+      if (command.getPermissions() != null && command.getPermissions().length > 0) {
+        softly.assertThatThrownBy(() -> bean.processCommand(command.getCommand()))
+            .describedAs(command.getCommand()).isInstanceOf(NotAuthorizedException.class)
+            .hasMessageContaining(command.getPermissions()[0].toString());
+        // }
       }
     }
+    softly.assertAll();
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/DataCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/DataCommandsSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/DataCommandsSecurityTest.java
index f746aaf..6269cf5 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/DataCommandsSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/DataCommandsSecurityTest.java
@@ -17,6 +17,13 @@ package org.apache.geode.management.internal.security;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.cache.Cache;
 import org.apache.geode.management.MemberMXBean;
 import org.apache.geode.security.GemFireSecurityException;
@@ -26,12 +33,6 @@ import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class DataCommandsSecurityTest {

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/DeployCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/DeployCommandsSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/DeployCommandsSecurityTest.java
index a4b8c67..9dd4d99 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/DeployCommandsSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/DeployCommandsSecurityTest.java
@@ -18,14 +18,8 @@ import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANA
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.Assert.assertTrue;
 
-import org.apache.geode.management.MemberMXBean;
-import org.apache.geode.security.NotAuthorizedException;
-import org.apache.geode.security.SimpleTestSecurityManager;
-import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
-import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
-import org.apache.geode.test.dunit.rules.ServerStarterRule;
-import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.apache.geode.test.junit.categories.SecurityTest;
+import java.io.File;
+
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
@@ -34,7 +28,14 @@ import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.rules.TemporaryFolder;
 
-import java.io.File;
+import org.apache.geode.management.MemberMXBean;
+import org.apache.geode.security.NotAuthorizedException;
+import org.apache.geode.security.SimpleTestSecurityManager;
+import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
+import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.geode.test.junit.categories.SecurityTest;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class DeployCommandsSecurityTest {
@@ -81,14 +82,7 @@ public class DeployCommandsSecurityTest {
         .isInstanceOf(NotAuthorizedException.class);
   }
 
-  @Test // only cluster access right is not enough to deploy
-  @ConnectionConfiguration(user = "cluster", password = "cluster")
-  public void testNoAccess3() {
-    assertThatThrownBy(() -> bean.processCommand(deployCommand))
-        .isInstanceOf(NotAuthorizedException.class);
-  }
-
-  @Test // not sufficient privalge
+  @Test // not sufficient privilege
   @ConnectionConfiguration(user = "clusterRead,clusterWrite,dataRead,dataWrite",
       password = "clusterRead,clusterWrite,dataRead,dataWrite")
   public void testNoAccess4() {

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
index e6502c0..4d101e7 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/DiskStoreMXBeanSecurityJUnitTest.java
@@ -17,13 +17,7 @@ package org.apache.geode.management.internal.security;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
-import org.apache.geode.management.DiskStoreMXBean;
-import org.apache.geode.security.TestSecurityManager;
-import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
-import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
-import org.apache.geode.test.dunit.rules.ServerStarterRule;
-import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.apache.geode.test.junit.categories.SecurityTest;
+import org.assertj.core.api.SoftAssertions;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
@@ -31,16 +25,21 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import org.apache.geode.management.DiskStoreMXBean;
+import org.apache.geode.security.SimpleTestSecurityManager;
+import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
+import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.geode.test.junit.categories.SecurityTest;
+
 @Category({IntegrationTest.class, SecurityTest.class})
 public class DiskStoreMXBeanSecurityJUnitTest {
   private DiskStoreMXBean bean;
 
   @ClassRule
   public static ServerStarterRule server = new ServerStarterRule().withJMXManager()
-      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
-      .withProperty(TestSecurityManager.SECURITY_JSON,
-          "org/apache/geode/management/internal/security/cacheServer.json")
-      .withAutoStart();
+      .withProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName()).withAutoStart();
 
   @BeforeClass
   public static void beforeClass() throws Exception {
@@ -57,7 +56,48 @@ public class DiskStoreMXBeanSecurityJUnitTest {
   }
 
   @Test
-  @ConnectionConfiguration(user = "data-admin", password = "1234567")
+  @ConnectionConfiguration(user = "clusterRead", password = "clusterRead")
+  public void testClusterReadAccess() throws Exception {
+    assertThatThrownBy(() -> bean.flush()).hasMessageContaining(TestCommand.diskManage.toString());
+    assertThatThrownBy(() -> bean.forceCompaction())
+        .hasMessageContaining(TestCommand.diskManage.toString());
+    assertThatThrownBy(() -> bean.forceRoll())
+        .hasMessageContaining(TestCommand.diskManage.toString());
+    assertThatThrownBy(() -> bean.setDiskUsageCriticalPercentage(0.5f))
+        .hasMessageContaining(TestCommand.diskManage.toString());
+    assertThatThrownBy(() -> bean.setDiskUsageWarningPercentage(0.5f))
+        .hasMessageContaining(TestCommand.diskManage.toString());
+
+    bean.getCompactionThreshold();
+    bean.getDiskDirectories();
+    bean.getDiskReadsRate();
+    bean.isAutoCompact();
+    bean.isForceCompactionAllowed();
+  }
+
+  @Test
+  @ConnectionConfiguration(user = "clusterManageDisk", password = "clusterManageDisk")
+  public void testDiskManageAccess() throws Exception {
+    assertThatThrownBy(() -> bean.getCompactionThreshold())
+        .hasMessageContaining(TestCommand.clusterRead.toString());
+    assertThatThrownBy(() -> bean.getDiskDirectories())
+        .hasMessageContaining(TestCommand.clusterRead.toString());
+    assertThatThrownBy(() -> bean.getDiskReadsRate())
+        .hasMessageContaining(TestCommand.clusterRead.toString());
+    assertThatThrownBy(() -> bean.isAutoCompact())
+        .hasMessageContaining(TestCommand.clusterRead.toString());
+    assertThatThrownBy(() -> bean.isForceCompactionAllowed())
+        .hasMessageContaining(TestCommand.clusterRead.toString());
+
+    bean.flush();
+    bean.forceCompaction();
+    bean.forceRoll();
+    bean.setDiskUsageCriticalPercentage(0.5f);
+    bean.setDiskUsageWarningPercentage(0.5f);
+  }
+
+  @Test
+  @ConnectionConfiguration(user = "data,cluster", password = "data,cluster")
   public void testAllAccess() throws Exception {
     bean.flush();
     bean.forceCompaction();
@@ -72,26 +112,30 @@ public class DiskStoreMXBeanSecurityJUnitTest {
   }
 
   @Test
-  @ConnectionConfiguration(user = "data-user", password = "1234567")
+  @ConnectionConfiguration(user = "noAccess", password = "noAccess")
   public void testNoAccess() throws Exception {
-    assertThatThrownBy(() -> bean.flush()).hasMessageContaining(TestCommand.dataManage.toString());
-    assertThatThrownBy(() -> bean.forceCompaction())
-        .hasMessageContaining(TestCommand.dataManage.toString());
-    assertThatThrownBy(() -> bean.forceRoll())
-        .hasMessageContaining(TestCommand.dataManage.toString());
-    assertThatThrownBy(() -> bean.getCompactionThreshold())
+    SoftAssertions softly = new SoftAssertions();
+
+    softly.assertThatThrownBy(() -> bean.flush())
+        .hasMessageContaining(TestCommand.clusterManageDisk.toString());
+    softly.assertThatThrownBy(() -> bean.forceCompaction())
+        .hasMessageContaining(TestCommand.clusterManageDisk.toString());
+    softly.assertThatThrownBy(() -> bean.forceRoll())
+        .hasMessageContaining(TestCommand.clusterManageDisk.toString());
+    softly.assertThatThrownBy(() -> bean.getCompactionThreshold())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.getDiskDirectories())
+    softly.assertThatThrownBy(() -> bean.getDiskDirectories())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.getDiskReadsRate())
+    softly.assertThatThrownBy(() -> bean.getDiskReadsRate())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.isAutoCompact())
+    softly.assertThatThrownBy(() -> bean.isAutoCompact())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.isForceCompactionAllowed())
+    softly.assertThatThrownBy(() -> bean.isForceCompactionAllowed())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.setDiskUsageCriticalPercentage(0.5f))
-        .hasMessageContaining(TestCommand.dataManage.toString());
-    assertThatThrownBy(() -> bean.setDiskUsageWarningPercentage(0.5f))
-        .hasMessageContaining(TestCommand.dataManage.toString());
+    softly.assertThatThrownBy(() -> bean.setDiskUsageCriticalPercentage(0.5f))
+        .hasMessageContaining(TestCommand.clusterManageDisk.toString());
+    softly.assertThatThrownBy(() -> bean.setDiskUsageWarningPercentage(0.5f))
+        .hasMessageContaining(TestCommand.clusterManageDisk.toString());
+    softly.assertAll();
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/DistributedSystemMXBeanSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/DistributedSystemMXBeanSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/DistributedSystemMXBeanSecurityTest.java
new file mode 100644
index 0000000..138aba6
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/DistributedSystemMXBeanSecurityTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.security;
+
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.management.DistributedSystemMXBean;
+import org.apache.geode.security.NotAuthorizedException;
+import org.apache.geode.security.SimpleTestSecurityManager;
+import org.apache.geode.security.TestSecurityManager;
+import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
+import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.categories.SecurityTest;
+
+@Category({DistributedTest.class, SecurityTest.class})
+public class DistributedSystemMXBeanSecurityTest {
+
+  private DistributedSystemMXBean bean;
+
+  @ClassRule
+  public static ServerStarterRule server = new ServerStarterRule().withJMXManager()
+      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
+      .withSecurityManager(SimpleTestSecurityManager.class).withAutoStart();
+
+  @Rule
+  public MBeanServerConnectionRule connectionRule =
+      new MBeanServerConnectionRule(server::getJmxPort);
+
+  @Before
+  public void setUp() throws Exception {
+    bean = connectionRule.getProxyMBean(DistributedSystemMXBean.class);
+  }
+
+  @Test
+  @ConnectionConfiguration(user = "dataRead", password = "dataRead")
+  public void testDataReadAccess() throws Exception {
+    assertThatThrownBy(() -> bean.backupAllMembers(null, null))
+        .isInstanceOf(NotAuthorizedException.class);
+  }
+
+  @Test
+  @ConnectionConfiguration(user = "clusterManageDisk", password = "clusterManageDisk")
+  public void testDiskManageAccess() throws Exception {
+    assertThatThrownBy(() -> bean.backupAllMembers(null, null))
+        .isInstanceOf(NotAuthorizedException.class);
+  }
+
+  @Test
+  @ConnectionConfiguration(user = "dataRead,clusterWriteDisk",
+      password = "dataRead,clusterWriteDisk")
+  public void testBothAccess() throws Exception {
+    assertThatThrownBy(() -> bean.backupAllMembers(null, null))
+        .isNotInstanceOf(NotAuthorizedException.class);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewayReceiverMBeanSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewayReceiverMBeanSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewayReceiverMBeanSecurityTest.java
index 73783d5..3257edb 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewayReceiverMBeanSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewayReceiverMBeanSecurityTest.java
@@ -15,17 +15,11 @@
 package org.apache.geode.management.internal.security;
 
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Mockito.mock;
 
-import org.apache.geode.management.GatewayReceiverMXBean;
-import org.apache.geode.management.ManagementService;
-import org.apache.geode.security.TestSecurityManager;
-import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
-import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
-import org.apache.geode.test.dunit.rules.ServerStarterRule;
-import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.apache.geode.test.junit.categories.SecurityTest;
+import javax.management.ObjectName;
+
+import org.assertj.core.api.SoftAssertions;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -34,7 +28,14 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import javax.management.ObjectName;
+import org.apache.geode.management.GatewayReceiverMXBean;
+import org.apache.geode.management.ManagementService;
+import org.apache.geode.security.SimpleTestSecurityManager;
+import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
+import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.geode.test.junit.categories.SecurityTest;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class GatewayReceiverMBeanSecurityTest {
@@ -47,10 +48,7 @@ public class GatewayReceiverMBeanSecurityTest {
 
   @ClassRule
   public static ServerStarterRule server = new ServerStarterRule().withJMXManager()
-      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
-      .withProperty(TestSecurityManager.SECURITY_JSON,
-          "org/apache/geode/management/internal/security/cacheServer.json")
-      .withAutoStart();
+      .withProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName()).withAutoStart();
 
   @Rule
   public MBeanServerConnectionRule connectionRule =
@@ -58,7 +56,7 @@ public class GatewayReceiverMBeanSecurityTest {
 
   @BeforeClass
   public static void beforeClass() throws Exception {
-    // the server does not have a GAtewayReceiverMXBean registered initially, has to register a mock
+    // the server does not have a GatewayReceiverMXBean registered initially, has to register a mock
     // one.
     service = ManagementService.getManagementService(server.getCache());
     mockBeanName = ObjectName.getInstance("GemFire", "key", "value");
@@ -76,7 +74,7 @@ public class GatewayReceiverMBeanSecurityTest {
   }
 
   @Test
-  @ConnectionConfiguration(user = "data-admin", password = "1234567")
+  @ConnectionConfiguration(user = "data,cluster", password = "data,cluster")
   public void testAllAccess() throws Exception {
     bean.getAverageBatchProcessingTime();
     bean.getBindAddress();
@@ -87,12 +85,16 @@ public class GatewayReceiverMBeanSecurityTest {
   }
 
   @Test
-  @ConnectionConfiguration(user = "data-user", password = "1234567")
+  @ConnectionConfiguration(user = "user", password = "user")
   public void testNoAccess() throws Exception {
-    assertThatThrownBy(() -> bean.getTotalConnectionsTimedOut())
+    SoftAssertions softly = new SoftAssertions();
+    softly.assertThatThrownBy(() -> bean.getTotalConnectionsTimedOut())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.start()).hasMessageContaining(TestCommand.dataManage.toString());
-    assertThatThrownBy(() -> bean.stop()).hasMessageContaining(TestCommand.dataManage.toString());
+    softly.assertThatThrownBy(() -> bean.start())
+        .hasMessageContaining(TestCommand.clusterManageGateway.toString());
+    softly.assertThatThrownBy(() -> bean.stop())
+        .hasMessageContaining(TestCommand.clusterManageGateway.toString());
+    softly.assertAll();
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewaySenderMBeanSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewaySenderMBeanSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewaySenderMBeanSecurityTest.java
index 887d0dc..3faa73e 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewaySenderMBeanSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/GatewaySenderMBeanSecurityTest.java
@@ -15,18 +15,11 @@
 package org.apache.geode.management.internal.security;
 
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Mockito.mock;
 
-import org.apache.geode.management.GatewaySenderMXBean;
-import org.apache.geode.management.ManagementService;
-import org.apache.geode.management.internal.beans.GatewaySenderMBean;
-import org.apache.geode.security.TestSecurityManager;
-import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
-import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
-import org.apache.geode.test.dunit.rules.ServerStarterRule;
-import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.apache.geode.test.junit.categories.SecurityTest;
+import javax.management.ObjectName;
+
+import org.assertj.core.api.SoftAssertions;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -35,7 +28,15 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import javax.management.ObjectName;
+import org.apache.geode.management.GatewaySenderMXBean;
+import org.apache.geode.management.ManagementService;
+import org.apache.geode.management.internal.beans.GatewaySenderMBean;
+import org.apache.geode.security.SimpleTestSecurityManager;
+import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
+import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
+import org.apache.geode.test.dunit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.geode.test.junit.categories.SecurityTest;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class GatewaySenderMBeanSecurityTest {
@@ -47,10 +48,7 @@ public class GatewaySenderMBeanSecurityTest {
 
   @ClassRule
   public static ServerStarterRule server = new ServerStarterRule().withJMXManager()
-      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
-      .withProperty(TestSecurityManager.SECURITY_JSON,
-          "org/apache/geode/management/internal/security/cacheServer.json")
-      .withAutoStart();
+      .withProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName()).withAutoStart();
 
   @Rule
   public MBeanServerConnectionRule connectionRule =
@@ -58,7 +56,7 @@ public class GatewaySenderMBeanSecurityTest {
 
   @BeforeClass
   public static void beforeClass() throws Exception {
-    // the server does not have a GAtewaySenderMXBean registered initially, has to register a mock
+    // the server does not have a GatewaySenderMXBean registered initially, has to register a mock
     // one.
     service = ManagementService.getManagementService(server.getCache());
     mockBeanName = ObjectName.getInstance("GemFire", "key", "value");
@@ -76,7 +74,7 @@ public class GatewaySenderMBeanSecurityTest {
   }
 
   @Test
-  @ConnectionConfiguration(user = "data-admin", password = "1234567")
+  @ConnectionConfiguration(user = "data,cluster", password = "data,cluster")
   public void testAllAccess() throws Exception {
     bean.getAlertThreshold();
     bean.getAverageDistributionTimePerBatch();
@@ -93,28 +91,36 @@ public class GatewaySenderMBeanSecurityTest {
   }
 
   @Test
-  @ConnectionConfiguration(user = "stranger", password = "1234567")
+  @ConnectionConfiguration(user = "stranger", password = "stranger")
   public void testNoAccess() throws Exception {
-    assertThatThrownBy(() -> bean.getAlertThreshold())
+    SoftAssertions softly = new SoftAssertions();
+
+    softly.assertThatThrownBy(() -> bean.getAlertThreshold())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.getAverageDistributionTimePerBatch())
+    softly.assertThatThrownBy(() -> bean.getAverageDistributionTimePerBatch())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.getBatchSize())
+    softly.assertThatThrownBy(() -> bean.getBatchSize())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.getMaximumQueueMemory())
+    softly.assertThatThrownBy(() -> bean.getMaximumQueueMemory())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.getOrderPolicy())
+    softly.assertThatThrownBy(() -> bean.getOrderPolicy())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.isBatchConflationEnabled())
+    softly.assertThatThrownBy(() -> bean.isBatchConflationEnabled())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.isManualStart())
+    softly.assertThatThrownBy(() -> bean.isManualStart())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.pause()).hasMessageContaining(TestCommand.dataManage.toString());
-    assertThatThrownBy(() -> bean.rebalance())
-        .hasMessageContaining(TestCommand.dataManage.toString());
-    assertThatThrownBy(() -> bean.resume()).hasMessageContaining(TestCommand.dataManage.toString());
-    assertThatThrownBy(() -> bean.start()).hasMessageContaining(TestCommand.dataManage.toString());
-    assertThatThrownBy(() -> bean.stop()).hasMessageContaining(TestCommand.dataManage.toString());
+    softly.assertThatThrownBy(() -> bean.pause())
+        .hasMessageContaining(TestCommand.clusterManageGateway.toString());
+    softly.assertThatThrownBy(() -> bean.rebalance())
+        .hasMessageContaining(TestCommand.clusterManageGateway.toString());
+    softly.assertThatThrownBy(() -> bean.resume())
+        .hasMessageContaining(TestCommand.clusterManageGateway.toString());
+    softly.assertThatThrownBy(() -> bean.start())
+        .hasMessageContaining(TestCommand.clusterManageGateway.toString());
+    softly.assertThatThrownBy(() -> bean.stop())
+        .hasMessageContaining(TestCommand.clusterManageGateway.toString());
+
+    softly.assertAll();
   }
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
index 1486866..5603eab 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
@@ -18,19 +18,20 @@ import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANA
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_POST_PROCESSOR;
 import static org.assertj.core.api.Assertions.assertThat;
 
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.security.SimpleTestSecurityManager;
 import org.apache.geode.security.TestPostProcessor;
-import org.apache.geode.security.TestSecurityManager;
 import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class GfshCommandsPostProcessorTest {
@@ -38,10 +39,7 @@ public class GfshCommandsPostProcessorTest {
   @ClassRule
   public static ServerStarterRule serverStarter = new ServerStarterRule().withJMXManager()
       .withProperty(SECURITY_POST_PROCESSOR, TestPostProcessor.class.getName())
-      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
-      .withProperty("security-json",
-          "org/apache/geode/management/internal/security/cacheServer.json")
-      .withAutoStart();
+      .withProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName()).withAutoStart();
 
   @Rule
   public GfshShellConnectionRule gfshConnection = new GfshShellConnectionRule(
@@ -53,7 +51,7 @@ public class GfshCommandsPostProcessorTest {
   }
 
   @Test
-  @ConnectionConfiguration(user = "data-user", password = "1234567")
+  @ConnectionConfiguration(user = "dataWrite,dataRead", password = "dataWrite,dataRead")
   public void testGetPostProcess() throws Exception {
     gfshConnection.executeCommand("put --region=region1 --key=key1 --value=value1");
     gfshConnection.executeCommand("put --region=region1 --key=key2 --value=value2");
@@ -61,12 +59,12 @@ public class GfshCommandsPostProcessorTest {
 
     // for get command, assert the return value is processed
     String result = gfshConnection.execute("get --region=region1 --key=key1");
-    assertThat(result).contains("data-user/region1/key1/value1");
+    assertThat(result).contains("dataWrite,dataRead/region1/key1/value1");
 
     // for query command, assert the return values are processed
     result = gfshConnection.execute("query --query=\"select * from /region1\"");
-    assertThat(result).contains("data-user/null/null/value1");
-    assertThat(result).contains("data-user/null/null/value2");
-    assertThat(result).contains("data-user/null/null/value3");
+    assertThat(result).contains("dataWrite,dataRead/null/null/value1");
+    assertThat(result).contains("dataWrite,dataRead/null/null/value2");
+    assertThat(result).contains("dataWrite,dataRead/null/null/value3");
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
index 84ef3fc..c2be173 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
@@ -15,12 +15,20 @@
 package org.apache.geode.management.internal.security;
 
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.util.List;
+
+import org.apache.shiro.authz.permission.WildcardPermission;
+import org.assertj.core.api.SoftAssertions;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.management.cli.Result;
@@ -33,14 +41,6 @@ import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
-import org.apache.shiro.authz.permission.WildcardPermission;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.util.List;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class GfshCommandsSecurityTest {
@@ -49,7 +49,7 @@ public class GfshCommandsSecurityTest {
       .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
       .withProperty("security-json",
           "org/apache/geode/management/internal/security/cacheServer.json")
-      .withAutoStart();
+      .withRegion(RegionShortcut.REPLICATE_PERSISTENT, "persistentRegion");
 
   @Rule
   public GfshShellConnectionRule gfshConnection = new GfshShellConnectionRule(
@@ -75,82 +75,89 @@ public class GfshCommandsSecurityTest {
   @Test
   @ConnectionConfiguration(user = "cluster-reader", password = "1234567")
   public void testClusterReader() throws Exception {
-    runCommandsWithAndWithout("CLUSTER:READ");
+    runCommandsPermittedAndForbiddenBy("CLUSTER:READ");
   }
 
   @Test
   @ConnectionConfiguration(user = "cluster-writer", password = "1234567")
   public void testClusterWriter() throws Exception {
-    runCommandsWithAndWithout("CLUSTER:WRITE");
+    runCommandsPermittedAndForbiddenBy("CLUSTER:WRITE");
   }
 
   @Test
   @ConnectionConfiguration(user = "cluster-manager", password = "1234567")
   public void testClusterManager() throws Exception {
-    runCommandsWithAndWithout("CLUSTER:MANAGE");
+    runCommandsPermittedAndForbiddenBy("CLUSTER:MANAGE");
   }
 
   @Test
   @ConnectionConfiguration(user = "data-reader", password = "1234567")
   public void testDataReader() throws Exception {
-    runCommandsWithAndWithout("DATA:READ");
+    runCommandsPermittedAndForbiddenBy("DATA:READ");
   }
 
   @Test
   @ConnectionConfiguration(user = "data-writer", password = "1234567")
   public void testDataWriter() throws Exception {
-    runCommandsWithAndWithout("DATA:WRITE");
+    runCommandsPermittedAndForbiddenBy("DATA:WRITE");
   }
 
   @Test
   @ConnectionConfiguration(user = "data-manager", password = "1234567")
   public void testDataManager() throws Exception {
-    runCommandsWithAndWithout("DATA:MANAGE");
+    runCommandsPermittedAndForbiddenBy("DATA:MANAGE");
   }
 
   @Test
   @ConnectionConfiguration(user = "regionA-reader", password = "1234567")
   public void testRegionAReader() throws Exception {
-    runCommandsWithAndWithout("DATA:READ:RegionA");
+    runCommandsPermittedAndForbiddenBy("DATA:READ:RegionA");
   }
 
   @Test
   @ConnectionConfiguration(user = "regionA-writer", password = "1234567")
   public void testRegionAWriter() throws Exception {
-    runCommandsWithAndWithout("DATA:WRITE:RegionA");
+    runCommandsPermittedAndForbiddenBy("DATA:WRITE:RegionA");
   }
 
   @Test
   @ConnectionConfiguration(user = "regionA-manager", password = "1234567")
   public void testRegionAManager() throws Exception {
-    runCommandsWithAndWithout("DATA:MANAGE:RegionA");
+    runCommandsPermittedAndForbiddenBy("DATA:MANAGE:RegionA");
+  }
+
+  @Test
+  @ConnectionConfiguration(user = "super-user", password = "1234567")
+  public void testRegionSuperUser() throws Exception {
+    runCommandsPermittedAndForbiddenBy("*");
   }
 
-  private void runCommandsWithAndWithout(String permission) throws Exception {
+  private void runCommandsPermittedAndForbiddenBy(String permission) throws Exception {
     List<TestCommand> allPermitted =
         TestCommand.getPermittedCommands(new WildcardPermission(permission, true));
+    SoftAssertions softly = new SoftAssertions();
+
     for (TestCommand permitted : allPermitted) {
       System.out.println("Processing authorized command: " + permitted.getCommand());
       CommandResult result = gfshConnection.executeCommand(permitted.getCommand());
       assertNotNull(result);
 
       if (result.getResultData() instanceof ErrorResultData) {
-        assertNotEquals(ResultBuilder.ERRORCODE_UNAUTHORIZED,
-            ((ErrorResultData) result.getResultData()).getErrorCode());
+        softly.assertThat(ResultBuilder.ERRORCODE_UNAUTHORIZED).describedAs(permitted.getCommand())
+            .isNotEqualTo(((ErrorResultData) result.getResultData()).getErrorCode());
       } else {
-        assertEquals(Result.Status.OK, result.getStatus());
+        softly.assertThat(Result.Status.OK).describedAs(permitted.toString())
+            .isEqualTo(result.getStatus());
       }
     }
 
-    List<TestCommand> others = TestCommand.getCommands();
+    // skip no permission commands
+    List<TestCommand> others = TestCommand.getOnlineCommands();
     others.removeAll(allPermitted);
     for (TestCommand other : others) {
-      // skip no permission commands
-      if (other.getPermission() == null)
-        continue;
 
       System.out.println("Processing unauthorized command: " + other.getCommand());
-      CommandResult result = (CommandResult) gfshConnection.executeCommand(other.getCommand());
+      CommandResult result = gfshConnection.executeCommand(other.getCommand());
       int errorCode = ((ErrorResultData) result.getResultData()).getErrorCode();
 
       // for some commands there are pre execution checks to check for user input error, will skip
@@ -160,13 +167,12 @@ public class GfshCommandsSecurityTest {
         continue;
       }
 
-      assertEquals(ResultBuilder.ERRORCODE_UNAUTHORIZED,
-          ((ErrorResultData) result.getResultData()).getErrorCode());
-      String resultMessage = result.getContent().toString();
-      String permString = other.getPermission().toString();
-      assertTrue(resultMessage + " does not contain " + permString,
-          resultMessage.contains(permString));
+      softly.assertThat(ResultBuilder.ERRORCODE_UNAUTHORIZED).describedAs(other.getCommand())
+          .isEqualTo(((ErrorResultData) result.getResultData()).getErrorCode());
     }
+
+    softly.assertAll();
+
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/LockServiceMBeanAuthorizationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/LockServiceMBeanAuthorizationJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/LockServiceMBeanAuthorizationJUnitTest.java
index dad2e9c..dd5cd13 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/LockServiceMBeanAuthorizationJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/LockServiceMBeanAuthorizationJUnitTest.java
@@ -15,25 +15,26 @@
 package org.apache.geode.management.internal.security;
 
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import org.assertj.core.api.SoftAssertions;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 import org.apache.geode.cache.Cache;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.distributed.internal.locks.DLockService;
 import org.apache.geode.management.LockServiceMXBean;
-import org.apache.geode.security.TestSecurityManager;
+import org.apache.geode.security.SimpleTestSecurityManager;
 import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
 import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class LockServiceMBeanAuthorizationJUnitTest {
@@ -41,10 +42,7 @@ public class LockServiceMBeanAuthorizationJUnitTest {
 
   @ClassRule
   public static ServerStarterRule server = new ServerStarterRule().withJMXManager()
-      .withProperty(SECURITY_MANAGER, TestSecurityManager.class.getName())
-      .withProperty(TestSecurityManager.SECURITY_JSON,
-          "org/apache/geode/management/internal/security/cacheServer.json")
-      .withAutoStart();
+      .withProperty(SECURITY_MANAGER, SimpleTestSecurityManager.class.getName()).withAutoStart();
 
   @Rule
   public MBeanServerConnectionRule connectionRule =
@@ -68,7 +66,8 @@ public class LockServiceMBeanAuthorizationJUnitTest {
   }
 
   @Test
-  @ConnectionConfiguration(user = "data-admin", password = "1234567")
+  @ConnectionConfiguration(user = "clusterRead,clusterManage",
+      password = "clusterRead,clusterManage")
   public void testAllAccess() throws Exception {
     lockServiceMBean.becomeLockGrantor();
     lockServiceMBean.fetchGrantorMember();
@@ -78,24 +77,50 @@ public class LockServiceMBeanAuthorizationJUnitTest {
   }
 
   @Test
-  @ConnectionConfiguration(user = "cluster-admin", password = "1234567")
-  public void testSomeAccess() throws Exception {
-    assertThatThrownBy(() -> lockServiceMBean.becomeLockGrantor());
+  @ConnectionConfiguration(user = "clusterManage", password = "clusterManage")
+  public void testClusterManage() throws Exception {
+    SoftAssertions softly = new SoftAssertions();
+    lockServiceMBean.becomeLockGrantor(); // c:m
+    softly.assertThatThrownBy(() -> lockServiceMBean.fetchGrantorMember())
+        .hasMessageContaining(TestCommand.clusterRead.toString());
+    softly.assertThatThrownBy(() -> lockServiceMBean.getMemberCount())
+        .hasMessageContaining(TestCommand.clusterRead.toString());
+    softly.assertThatThrownBy(() -> lockServiceMBean.isDistributed())
+        .hasMessageContaining(TestCommand.clusterRead.toString());
+    softly.assertThatThrownBy(() -> lockServiceMBean.listThreadsHoldingLock())
+        .hasMessageContaining(TestCommand.clusterRead.toString());
+    softly.assertAll();
+  }
+
+  @Test
+  @ConnectionConfiguration(user = "clusterRead", password = "clusterRead")
+  public void testClusterRead() throws Exception {
+    SoftAssertions softly = new SoftAssertions();
+    softly.assertThatThrownBy(() -> lockServiceMBean.becomeLockGrantor())
+        .hasMessageContaining(TestCommand.clusterManage.toString());
+    lockServiceMBean.fetchGrantorMember();
     lockServiceMBean.getMemberCount();
+    lockServiceMBean.isDistributed();
+    lockServiceMBean.listThreadsHoldingLock();
+    softly.assertAll();
   }
 
   @Test
-  @ConnectionConfiguration(user = "data-user", password = "1234567")
+  @ConnectionConfiguration(user = "user", password = "user")
   public void testNoAccess() throws Exception {
-    assertThatThrownBy(() -> lockServiceMBean.becomeLockGrantor())
-        .hasMessageContaining(TestCommand.dataManage.toString());
-    assertThatThrownBy(() -> lockServiceMBean.fetchGrantorMember())
+    SoftAssertions softly = new SoftAssertions();
+
+    softly.assertThatThrownBy(() -> lockServiceMBean.becomeLockGrantor())
+        .hasMessageContaining(TestCommand.clusterManage.toString());
+    softly.assertThatThrownBy(() -> lockServiceMBean.fetchGrantorMember())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> lockServiceMBean.getMemberCount())
+    softly.assertThatThrownBy(() -> lockServiceMBean.getMemberCount())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> lockServiceMBean.isDistributed())
+    softly.assertThatThrownBy(() -> lockServiceMBean.isDistributed())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> lockServiceMBean.listThreadsHoldingLock())
+    softly.assertThatThrownBy(() -> lockServiceMBean.listThreadsHoldingLock())
         .hasMessageContaining(TestCommand.clusterRead.toString());
+
+    softly.assertAll();
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/MBeanSecurityJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/MBeanSecurityJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/MBeanSecurityJUnitTest.java
index 091b1db..187246d 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/MBeanSecurityJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/MBeanSecurityJUnitTest.java
@@ -19,6 +19,22 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Mockito.mock;
 
+import java.io.IOException;
+import java.util.Set;
+
+import javax.management.DynamicMBean;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerConnection;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.management.ManagementException;
 import org.apache.geode.management.ManagementService;
 import org.apache.geode.management.MemberMXBean;
@@ -29,20 +45,6 @@ import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.IOException;
-import java.util.Set;
-import javax.management.DynamicMBean;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class MBeanSecurityJUnitTest {

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java
index 77f68c3..73ffe97 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java
@@ -15,9 +15,20 @@
 package org.apache.geode.management.internal.security;
 
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Mockito.mock;
 
+import java.lang.management.ManagementFactory;
+
+import javax.management.ObjectName;
+
+import org.assertj.core.api.SoftAssertions;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.management.ManagerMXBean;
 import org.apache.geode.management.internal.beans.ManagerMBean;
 import org.apache.geode.security.TestSecurityManager;
@@ -26,15 +37,6 @@ import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.lang.management.ManagementFactory;
-import javax.management.ObjectName;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class ManagerMBeanAuthorizationJUnitTest {
@@ -76,10 +78,14 @@ public class ManagerMBeanAuthorizationJUnitTest {
   @Test
   @ConnectionConfiguration(user = "data-admin", password = "1234567")
   public void testSomeAccess() throws Exception {
-    assertThatThrownBy(() -> managerMXBean.start())
+    SoftAssertions softly = new SoftAssertions();
+
+    softly.assertThatThrownBy(() -> managerMXBean.start())
         .hasMessageContaining(TestCommand.clusterManage.toString());
-    assertThatThrownBy(() -> managerMXBean.getPulseURL())
+    softly.assertThatThrownBy(() -> managerMXBean.getPulseURL())
         .hasMessageContaining(TestCommand.clusterWrite.toString());
+
+    softly.assertAll();
     managerMXBean.isRunning();
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/MemberMBeanSecurityJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/MemberMBeanSecurityJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/MemberMBeanSecurityJUnitTest.java
index 77ddcc9..e6b50d2 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/MemberMBeanSecurityJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/MemberMBeanSecurityJUnitTest.java
@@ -17,6 +17,13 @@ package org.apache.geode.management.internal.security;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
+import org.assertj.core.api.SoftAssertions;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
+import org.junit.experimental.categories.Category;
+
 import org.apache.geode.management.MemberMXBean;
 import org.apache.geode.security.TestSecurityManager;
 import org.apache.geode.test.dunit.rules.ConnectionConfiguration;
@@ -24,11 +31,6 @@ import org.apache.geode.test.dunit.rules.MBeanServerConnectionRule;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.experimental.categories.Category;
 
 @Category({IntegrationTest.class, SecurityTest.class})
 public class MemberMBeanSecurityJUnitTest {
@@ -67,7 +69,6 @@ public class MemberMBeanSecurityJUnitTest {
     bean.isCacheServer();
     bean.isServer();
     bean.listConnectedGatewayReceivers();
-    // bean.processCommand("create region --name=Region_A");
     bean.showJVMMetrics();
     bean.status();
   }
@@ -75,8 +76,7 @@ public class MemberMBeanSecurityJUnitTest {
   @Test
   @ConnectionConfiguration(user = "cluster-admin", password = "1234567")
   public void testClusterAdmin() throws Exception {
-    assertThatThrownBy(() -> bean.compactAllDiskStores())
-        .hasMessageContaining(TestCommand.dataManage.toString());
+    bean.compactAllDiskStores();
     bean.shutDownMember();
     bean.createManager();
     bean.fetchJvmThreads();
@@ -93,7 +93,8 @@ public class MemberMBeanSecurityJUnitTest {
   @Test
   @ConnectionConfiguration(user = "data-admin", password = "1234567")
   public void testDataAdmin() throws Exception {
-    bean.compactAllDiskStores();
+    assertThatThrownBy(() -> bean.compactAllDiskStores())
+        .hasMessageContaining(TestCommand.clusterManageDisk.toString());
     assertThatThrownBy(() -> bean.shutDownMember())
         .hasMessageContaining(TestCommand.clusterManage.toString());
     assertThatThrownBy(() -> bean.createManager())
@@ -105,31 +106,35 @@ public class MemberMBeanSecurityJUnitTest {
   @Test
   @ConnectionConfiguration(user = "data-user", password = "1234567")
   public void testDataUser() throws Exception {
-    assertThatThrownBy(() -> bean.shutDownMember())
+    SoftAssertions softly = new SoftAssertions();
+
+    softly.assertThatThrownBy(() -> bean.shutDownMember())
         .hasMessageContaining(TestCommand.clusterManage.toString());
-    assertThatThrownBy(() -> bean.createManager())
+    softly.assertThatThrownBy(() -> bean.createManager())
         .hasMessageContaining(TestCommand.clusterManage.toString());
-    assertThatThrownBy(() -> bean.compactAllDiskStores())
-        .hasMessageContaining(TestCommand.dataManage.toString());
-    assertThatThrownBy(() -> bean.fetchJvmThreads())
+    softly.assertThatThrownBy(() -> bean.compactAllDiskStores())
+        .hasMessageContaining(TestCommand.clusterManageDisk.toString());
+    softly.assertThatThrownBy(() -> bean.fetchJvmThreads())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.getName())
+    softly.assertThatThrownBy(() -> bean.getName())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.getDiskStores())
+    softly.assertThatThrownBy(() -> bean.getDiskStores())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.hasGatewayReceiver())
+    softly.assertThatThrownBy(() -> bean.hasGatewayReceiver())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.isCacheServer())
+    softly.assertThatThrownBy(() -> bean.isCacheServer())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.isServer())
+    softly.assertThatThrownBy(() -> bean.isServer())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.listConnectedGatewayReceivers())
+    softly.assertThatThrownBy(() -> bean.listConnectedGatewayReceivers())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.processCommand("create region --name=Region_A"))
+    softly.assertThatThrownBy(() -> bean.processCommand("create region --name=Region_A"))
         .hasMessageContaining(TestCommand.dataManage.toString());
-    assertThatThrownBy(() -> bean.showJVMMetrics())
+    softly.assertThatThrownBy(() -> bean.showJVMMetrics())
         .hasMessageContaining(TestCommand.clusterRead.toString());
-    assertThatThrownBy(() -> bean.status())
+    softly.assertThatThrownBy(() -> bean.status())
         .hasMessageContaining(TestCommand.clusterRead.toString());
+
+    softly.assertAll();
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/MultiUserDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/MultiUserDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/MultiUserDUnitTest.java
index 255048d..e3fe173 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/MultiUserDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/MultiUserDUnitTest.java
@@ -18,12 +18,21 @@ import static org.apache.geode.distributed.ConfigurationProperties.NAME;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import org.awaitility.Awaitility;
+import org.json.JSONException;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.management.cli.Result.Status;
-import org.apache.geode.management.internal.cli.HeadlessGfsh;
-import org.apache.geode.management.internal.cli.commands.CliCommandTestBase;
 import org.apache.geode.management.internal.cli.result.CommandResult;
 import org.apache.geode.management.internal.cli.result.ErrorResultData;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
@@ -32,67 +41,62 @@ import org.apache.geode.test.dunit.AsyncInvocation;
 import org.apache.geode.test.dunit.Host;
 import org.apache.geode.test.dunit.IgnoredException;
 import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
+import org.apache.geode.test.dunit.rules.GfshShellConnectionRule.PortType;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.Member;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
-import org.awaitility.Awaitility;
-import org.json.JSONException;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
 
 @Category({DistributedTest.class, SecurityTest.class})
-public class MultiUserDUnitTest extends CliCommandTestBase {
+public class MultiUserDUnitTest {
 
-  @Category(FlakyTest.class) // GEODE-1579
-  @Test
-  public void testMultiUser() throws IOException, JSONException, InterruptedException {
-    IgnoredException.addIgnoredException("java.util.zip.ZipException: zip file is empty");
+  @Rule
+  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
+
+  private Member server;
 
+  @Before
+  public void setup() throws Exception {
     Properties properties = new Properties();
     properties.put(NAME, MultiUserDUnitTest.class.getSimpleName());
     properties.put(SECURITY_MANAGER, TestSecurityManager.class.getName());
-
-    // set up vm_0 the secure jmx manager
-    Object[] results = setUpJMXManagerOnVM(0, properties,
+    properties.put("security-json",
         "org/apache/geode/management/internal/security/cacheServer.json");
-    String gfshDir = this.gfshDir;
+    server = lsRule.startServerAsJmxManager(0, properties);
+  }
+
+  @Category(FlakyTest.class) // GEODE-1579
+  @Test
+  public void testMultiUser() throws IOException, JSONException, InterruptedException {
+
+    IgnoredException.addIgnoredException("java.util.zip.ZipException: zip file is empty");
+    int jmxPort = server.getJmxPort();
 
     // set up vm_1 as a gfsh vm, data-reader will login and log out constantly in this vm until the
     // test is done.
     VM vm1 = Host.getHost(0).getVM(1);
     AsyncInvocation vm1Invoke = vm1.invokeAsync("run as data-reader", () -> {
-      String shellId = getClass().getSimpleName() + "_vm1";
-      HeadlessGfsh shell = new HeadlessGfsh(shellId, 30, gfshDir);
-      while (true) {
-        connect((String) results[0], (Integer) results[1], (Integer) results[2], shell,
-            "data-reader", "1234567");
-        Awaitility.waitAtMost(5, TimeUnit.MILLISECONDS);
-        shell.executeCommand("disconnect");
-      }
+      GfshShellConnectionRule gfsh = new GfshShellConnectionRule();
+      gfsh.secureConnectAndVerify(jmxPort, PortType.jmxManger, "data-reader", "1234567");
+
+      Awaitility.waitAtMost(5, TimeUnit.MILLISECONDS);
+      gfsh.close();
     });
 
     VM vm2 = Host.getHost(0).getVM(2);
     // set up vm_2 as a gfsh vm, and then connect as "stranger" and try to execute the commands and
     // assert errors comes back are NotAuthorized
     AsyncInvocation vm2Invoke = vm2.invokeAsync("run as guest", () -> {
-      String shellId = getClass().getSimpleName() + "_vm2";
-      HeadlessGfsh shell = new HeadlessGfsh(shellId, 30, gfshDir);
-      connect((String) results[0], (Integer) results[1], (Integer) results[2], shell, "stranger",
-          "1234567");
+      GfshShellConnectionRule gfsh = new GfshShellConnectionRule();
+      gfsh.secureConnectAndVerify(jmxPort, PortType.jmxManger, "stranger", "1234567");
 
-      List<TestCommand> allCommands = TestCommand.getCommands();
+      List<TestCommand> allCommands = TestCommand.getOnlineCommands();
       for (TestCommand command : allCommands) {
         LogService.getLogger().info("executing: " + command.getCommand());
-        if (command.getPermission() == null) {
-          continue;
-        }
 
-        CommandResult result = executeCommand(shell, command.getCommand());
+        CommandResult result = gfsh.executeCommand(command.getCommand());
 
         int errorCode = ((ErrorResultData) result.getResultData()).getErrorCode();
 
@@ -106,11 +110,9 @@ public class MultiUserDUnitTest extends CliCommandTestBase {
         assertEquals("Not an expected result: " + result.toString(),
             ResultBuilder.ERRORCODE_UNAUTHORIZED,
             ((ErrorResultData) result.getResultData()).getErrorCode());
-        String resultMessage = result.getContent().toString();
-        String permString = command.getPermission().toString();
-        assertTrue(resultMessage + " does not contain " + permString,
-            resultMessage.contains(permString));
+
       }
+      gfsh.close();
       LogService.getLogger().info("vm 2 done!");
     });
 
@@ -123,28 +125,22 @@ public class MultiUserDUnitTest extends CliCommandTestBase {
     // set up vm_3 as another gfsh vm, and then connect as "super-user" and try to execute the
     // commands and assert we don't get a NotAuthorized Exception
     AsyncInvocation vm3Invoke = vm3.invokeAsync("run as superUser", () -> {
-      String shellId = getClass().getSimpleName() + "_vm3";
-      HeadlessGfsh shell = new HeadlessGfsh(shellId, 30, gfshDir);
-      connect((String) results[0], (Integer) results[1], (Integer) results[2], shell, "super-user",
-          "1234567");
+      GfshShellConnectionRule gfsh = new GfshShellConnectionRule();
+      gfsh.secureConnectAndVerify(jmxPort, PortType.jmxManger, "super-user", "1234567");
 
-      List<TestCommand> allCommands = TestCommand.getCommands();
+      List<TestCommand> allCommands = TestCommand.getOnlineCommands();
       for (TestCommand command : allCommands) {
         LogService.getLogger().info("executing: " + command.getCommand());
-        if (command.getPermission() == null) {
-          continue;
-        }
 
-        CommandResult result = executeCommand(shell, command.getCommand());
+        CommandResult result = gfsh.executeCommand(command.getCommand());
         if (result.getResultData().getStatus() == Status.OK) {
           continue;
         }
-
         assertNotEquals("Did not expect an Unauthorized exception: " + result.toString(),
             ResultBuilder.ERRORCODE_UNAUTHORIZED,
             ((ErrorResultData) result.getResultData()).getErrorCode());
       }
-
+      gfsh.close();
       LogService.getLogger().info("vm 3 done!");
     });
 

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/test/java/org/apache/geode/management/internal/security/ResourcePermissionTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/ResourcePermissionTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/ResourcePermissionTest.java
index 51f8c5e..54db58e 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/ResourcePermissionTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/ResourcePermissionTest.java
@@ -16,18 +16,17 @@ package org.apache.geode.management.internal.security;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+
+import org.apache.shiro.authz.permission.WildcardPermission;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 import org.apache.geode.security.ResourcePermission;
-import org.apache.geode.security.ResourcePermission.Target;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
+import org.apache.geode.security.ResourcePermission.Target;
 import org.apache.geode.test.junit.categories.SecurityTest;
 import org.apache.geode.test.junit.categories.UnitTest;
-import org.apache.shiro.authz.permission.WildcardPermission;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
 
 @Category({UnitTest.class, SecurityTest.class})
 public class ResourcePermissionTest {
@@ -110,7 +109,7 @@ public class ResourcePermissionTest {
   }
 
   @Test
-  public void testImples() {
+  public void testImplies() {
     WildcardPermission role = new WildcardPermission("*:read");
     role.implies(new ResourcePermission(Resource.DATA, Operation.READ));
     role.implies(new ResourcePermission(Resource.CLUSTER, Operation.READ));


[42/46] geode git commit: Move new exception to sanctioned serializables.

Posted by zh...@apache.org.
Move new exception to sanctioned serializables.

Although we don't serialize it, exceptions sometimes get sent between
JVMs so it's best to be careful.


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

Branch: refs/heads/feature/GEM-1483
Commit: e1c6c3a973413045c595fcf31a01c269e7df7e82
Parents: da64fc6
Author: Galen OSullivan <go...@pivotal.io>
Authored: Fri Jun 23 10:42:45 2017 -0700
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Mon Jun 26 09:26:23 2017 -0700

----------------------------------------------------------------------
 .../resources/org/apache/geode/codeAnalysis/excludedClasses.txt     | 1 -
 .../org/apache/geode/codeAnalysis/sanctionedSerializables.txt       | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/e1c6c3a9/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
index c2629f1..6a6e0c1 100644
--- a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
+++ b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt
@@ -7,7 +7,6 @@ org/apache/geode/distributed/LocatorLauncher$Command
 org/apache/geode/distributed/ServerLauncher
 org/apache/geode/distributed/ServerLauncher$Command
 org/apache/geode/distributed/internal/DistributionManager
-org/apache/geode/internal/cache/tier/sockets/ServiceLoadingFailureException
 org/apache/geode/internal/JarDeployer
 org/apache/geode/internal/logging/GemFireLevel
 org/apache/geode/internal/logging/LoggingThreadGroup

http://git-wip-us.apache.org/repos/asf/geode/blob/e1c6c3a9/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 135f509..e5a111c 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
@@ -340,6 +340,7 @@ org/apache/geode/internal/cache/tier/sockets/CacheClientNotifier$2,false,this$0:
 org/apache/geode/internal/cache/tier/sockets/CacheClientProxy$MessageDispatcher$1,true,0,this$0:org/apache/geode/internal/cache/tier/sockets/CacheClientProxy$MessageDispatcher
 org/apache/geode/internal/cache/tier/sockets/ClientTombstoneMessage$TOperation,false
 org/apache/geode/internal/cache/tier/sockets/MessageTooLargeException,true,-8970585803331525833
+org/apache/geode/internal/cache/tier/sockets/ServiceLoadingFailureException,false
 org/apache/geode/internal/cache/tier/sockets/UnregisterAllInterest,true,5026160621257178459
 org/apache/geode/internal/cache/tx/TransactionalOperation$ServerRegionOperation,false
 org/apache/geode/internal/cache/versions/ConcurrentCacheModificationException,true,2316928221010347462


[32/46] geode git commit: GEODE-3075: Add an integration test for the ServerConnectionFactory

Posted by zh...@apache.org.
GEODE-3075: Add an integration test for the ServerConnectionFactory

the current implementation is bogus, but does test that the flow works.


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

Branch: refs/heads/feature/GEM-1483
Commit: 4ace36af00a22e0995a2e0d07db75f5508524a25
Parents: dfdde4a
Author: Galen OSullivan <go...@pivotal.io>
Authored: Fri Jun 16 09:59:11 2017 -0700
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Mon Jun 26 09:26:22 2017 -0700

----------------------------------------------------------------------
 .../sockets/ClientProtocolMessageHandler.java   |  8 ++-
 .../sockets/NewProtocolServerConnection.java    |  7 ++-
 .../ServerConnectionFactoryIntegrationTest.java | 66 ++++++++++++++++++++
 .../sockets/ServerConnectionFactoryTest.java    | 44 ++++++-------
 4 files changed, 100 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/4ace36af/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java
index db42330..702609d 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java
@@ -17,6 +17,7 @@ package org.apache.geode.internal.cache.tier.sockets;
 
 import org.apache.geode.internal.cache.InternalCache;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 
@@ -24,6 +25,11 @@ import java.io.OutputStream;
  * Stub, this will be hooked up to the new client protocol when it's implemented.
  */
 public class ClientProtocolMessageHandler {
+  /**
+   * Bogus, but it lets us write an integration test so that nobody breaks our flow.
+   */
   public void receiveMessage(InputStream inputStream, OutputStream outputStream,
-      InternalCache cache) {}
+      InternalCache cache) throws IOException {
+    outputStream.write(inputStream.read());
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/4ace36af/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/NewProtocolServerConnection.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/NewProtocolServerConnection.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/NewProtocolServerConnection.java
index a78cd1c..83b23b1 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/NewProtocolServerConnection.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/NewProtocolServerConnection.java
@@ -50,9 +50,9 @@ public class NewProtocolServerConnection extends ServerConnection {
    * @param acceptor
    */
   public NewProtocolServerConnection(Socket s, InternalCache c, CachedRegionHelper helper,
-                                     CacheServerStats stats, int hsTimeout, int socketBufferSize, String communicationModeStr,
-                                     byte communicationMode, Acceptor acceptor, ClientProtocolMessageHandler newClientProtocol,
-                                     SecurityService securityService) {
+      CacheServerStats stats, int hsTimeout, int socketBufferSize, String communicationModeStr,
+      byte communicationMode, Acceptor acceptor, ClientProtocolMessageHandler newClientProtocol,
+      SecurityService securityService) {
     super(s, c, helper, stats, hsTimeout, socketBufferSize, communicationModeStr, communicationMode,
         acceptor, securityService);
     assert (communicationMode == AcceptorImpl.CLIENT_TO_SERVER_NEW_PROTOCOL);
@@ -65,6 +65,7 @@ public class NewProtocolServerConnection extends ServerConnection {
       Socket socket = this.getSocket();
       InputStream inputStream = socket.getInputStream();
       OutputStream outputStream = socket.getOutputStream();
+
       // TODO serialization types?
       newClientProtocol.receiveMessage(inputStream, outputStream, this.getCache());
     } catch (IOException e) {

http://git-wip-us.apache.org/repos/asf/geode/blob/4ace36af/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java
new file mode 100644
index 0000000..007d1d6
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.internal.cache.tier.sockets;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.server.CacheServer;
+import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.internal.cache.tier.Acceptor;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.awaitility.Awaitility;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.IOException;
+import java.net.Socket;
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Test that switching on the header byte makes instances of {@link NewProtocolServerConnection}.
+ */
+@Category(IntegrationTest.class)
+public class ServerConnectionFactoryIntegrationTest {
+  /**
+   *
+   * @throws IOException
+   */
+  @Test
+  public void testNewProtocolHeaderLeadsToNewProtocolServerConnection() throws IOException {
+    System.setProperty("geode.feature-protobuf-protocol", "true");
+    try {
+      CacheFactory cacheFactory = new CacheFactory();
+      Cache cache = cacheFactory.create();
+
+      CacheServer cacheServer = cache.addCacheServer();
+      final int cacheServerPort = AvailablePortHelper.getRandomAvailableTCPPort();
+      cacheServer.setPort(cacheServerPort);
+      cacheServer.start();
+
+      Socket socket = new Socket("localhost", cacheServerPort);
+      Awaitility.await().atMost(5, TimeUnit.SECONDS).until(socket::isConnected);
+      socket.getOutputStream().write(Acceptor.CLIENT_TO_SERVER_NEW_PROTOCOL);
+      socket.getOutputStream().write(222);
+      assertEquals(222, socket.getInputStream().read());
+
+      cache.close();
+    } finally {
+      System.clearProperty("geode.feature-protobuf-protocol");
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/4ace36af/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java
index c314944..8e241b2 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java
@@ -19,18 +19,23 @@ import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.tier.Acceptor;
 import org.apache.geode.internal.cache.tier.CachedRegionHelper;
 import org.apache.geode.internal.security.SecurityService;
+import org.apache.geode.test.junit.categories.UnitTest;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 import java.io.IOException;
 import java.net.InetAddress;
 import java.net.Socket;
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
+@Category(UnitTest.class)
 public class ServerConnectionFactoryTest {
   /**
-   * Safeguard that we won't create the new client protocol object unless the feature flag is enabled.
+   * Safeguard that we won't create the new client protocol object unless the feature flag is
+   * enabled.
    */
   @Test(expected = IOException.class)
   public void newClientProtocolThrows() throws Exception {
@@ -40,38 +45,35 @@ public class ServerConnectionFactoryTest {
   @Test
   public void newClientProtocolSucceedsWithSystemPropertySet() throws Exception {
     System.setProperty("geode.feature-protobuf-protocol", "true");
-    ServerConnection serverConnection = serverConnectionMockedExceptForCommunicationMode(Acceptor.CLIENT_TO_SERVER_NEW_PROTOCOL);
+    ServerConnection serverConnection =
+        serverConnectionMockedExceptForCommunicationMode(Acceptor.CLIENT_TO_SERVER_NEW_PROTOCOL);
     assertTrue(serverConnection instanceof NewProtocolServerConnection);
     System.clearProperty("geode.feature-protobuf-protocol");
   }
 
   @Test
   public void makeServerConnection() throws Exception {
-    byte[] communicationModes = new byte[]{
-      Acceptor.CLIENT_TO_SERVER,
-      Acceptor.PRIMARY_SERVER_TO_CLIENT,
-      Acceptor.SECONDARY_SERVER_TO_CLIENT,
-      Acceptor.GATEWAY_TO_GATEWAY,
-      Acceptor.MONITOR_TO_SERVER,
-      Acceptor.SUCCESSFUL_SERVER_TO_CLIENT,
-      Acceptor.UNSUCCESSFUL_SERVER_TO_CLIENT,
-      Acceptor.CLIENT_TO_SERVER_FOR_QUEUE,
-    };
+    byte[] communicationModes =
+        new byte[] {Acceptor.CLIENT_TO_SERVER, Acceptor.PRIMARY_SERVER_TO_CLIENT,
+            Acceptor.SECONDARY_SERVER_TO_CLIENT, Acceptor.GATEWAY_TO_GATEWAY,
+            Acceptor.MONITOR_TO_SERVER, Acceptor.SUCCESSFUL_SERVER_TO_CLIENT,
+            Acceptor.UNSUCCESSFUL_SERVER_TO_CLIENT, Acceptor.CLIENT_TO_SERVER_FOR_QUEUE,};
 
     for (byte communicationMode : communicationModes) {
-      ServerConnection serverConnection = serverConnectionMockedExceptForCommunicationMode(communicationMode);
+      ServerConnection serverConnection =
+          serverConnectionMockedExceptForCommunicationMode(communicationMode);
       assertTrue(serverConnection instanceof LegacyServerConnection);
     }
   }
 
-  private static ServerConnection serverConnectionMockedExceptForCommunicationMode(byte communicationMode) throws IOException {
+  private static ServerConnection serverConnectionMockedExceptForCommunicationMode(
+      byte communicationMode) throws IOException {
     Socket socketMock = mock(Socket.class);
     when(socketMock.getInetAddress()).thenReturn(InetAddress.getByName("localhost"));
 
-    return ServerConnectionFactory.makeServerConnection(
-      socketMock, mock(InternalCache.class), mock(CachedRegionHelper.class),
-      mock(CacheServerStats.class), 0, 0, "",
-      communicationMode, mock(AcceptorImpl.class), mock(SecurityService.class));
+    return ServerConnectionFactory.makeServerConnection(socketMock, mock(InternalCache.class),
+        mock(CachedRegionHelper.class), mock(CacheServerStats.class), 0, 0, "", communicationMode,
+        mock(AcceptorImpl.class), mock(SecurityService.class));
   }
 
-}
\ No newline at end of file
+}


[41/46] geode git commit: GEODE-3075: fix an integration test.

Posted by zh...@apache.org.
GEODE-3075: fix an integration test.

I think the test fails because another test doesn't clean up system
properties when it's done.


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

Branch: refs/heads/feature/GEM-1483
Commit: e62e825090db50f77faaa3e222595ee1026d7a6c
Parents: a3c66e1
Author: Galen OSullivan <go...@pivotal.io>
Authored: Wed Jun 21 14:01:01 2017 -0700
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Mon Jun 26 09:26:23 2017 -0700

----------------------------------------------------------------------
 .../cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/e62e8250/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java
index 82c4e54..9a1509f 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java
@@ -46,7 +46,9 @@ public class ServerConnectionFactoryIntegrationTest {
   @Test
   public void testNewProtocolHeaderLeadsToNewProtocolServerConnection() throws IOException {
     System.setProperty("geode.feature-protobuf-protocol", "true");
+
     CacheFactory cacheFactory = new CacheFactory();
+    cacheFactory.set("mcast-port","0"); //sometimes it isn't due to other tests.
     Cache cache = cacheFactory.create();
 
     CacheServer cacheServer = cache.addCacheServer();


[38/46] geode git commit: GEODE-2995: Implementing review feedback

Posted by zh...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java
new file mode 100644
index 0000000..95244d2
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java
@@ -0,0 +1,81 @@
+/*
+ * 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.protocol.serializer;
+
+import org.apache.geode.client.protocol.MessageUtil;
+import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
+import org.apache.geode.protocol.protobuf.serializer.ProtobufProtocolSerializer;
+import org.apache.geode.protocol.protobuf.ClientProtocol;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ServiceLoader;
+
+@Category(UnitTest.class)
+public class ProtobufProtocolSerializerJUnitTest {
+  private ProtocolSerializer<ClientProtocol.Message> protocolSerializer;
+
+  @Before
+  public void startup() {
+    ServiceLoader<ProtocolSerializer> serviceLoader = ServiceLoader.load(ProtocolSerializer.class);
+    for (ProtocolSerializer protocolSerializer : serviceLoader) {
+      if (protocolSerializer instanceof ProtobufProtocolSerializer) {
+        this.protocolSerializer = protocolSerializer;
+      }
+    }
+  }
+
+  @Test
+  public void testDeserializeByteArrayToMessage()
+      throws IOException, InvalidProtocolMessageException {
+    ClientProtocol.Message expectedRequestMessage = MessageUtil.createGetRequestMessage();
+
+    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+
+    expectedRequestMessage.writeDelimitedTo(byteArrayOutputStream);
+    InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
+
+    ClientProtocol.Message actualMessage = protocolSerializer.deserialize(inputStream);
+    Assert.assertEquals(expectedRequestMessage, actualMessage);
+  }
+
+  @Test(expected = InvalidProtocolMessageException.class)
+  public void testDeserializeInvalidByteThrowsException()
+    throws IOException, InvalidProtocolMessageException {
+    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+    byteArrayOutputStream.write("Some incorrect byte array".getBytes());
+    InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
+    protocolSerializer.deserialize(inputStream);
+  }
+
+  @Test
+  public void testSerializeMessageToByteArray() throws IOException {
+    ClientProtocol.Message message = MessageUtil.createGetRequestMessage();
+    ByteArrayOutputStream expectedByteArrayOutputStream = new ByteArrayOutputStream();
+    message.writeDelimitedTo(expectedByteArrayOutputStream);
+    byte[] expectedByteArray = expectedByteArrayOutputStream.toByteArray();
+
+    ByteArrayOutputStream actualByteArrayOutputStream = new ByteArrayOutputStream();
+    protocolSerializer.serialize(message, actualByteArrayOutputStream);
+    Assert.assertArrayEquals(expectedByteArray, actualByteArrayOutputStream.toByteArray());
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceImplTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceImplTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceImplTest.java
index a4c0a14..ef841c3 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceImplTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceImplTest.java
@@ -15,6 +15,7 @@
 package org.apache.geode.serialization;
 
 import org.apache.geode.protocol.protobuf.BasicTypes;
+import org.apache.geode.protocol.protobuf.ProtobufSerializationService;
 import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
 import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
 import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
@@ -51,7 +52,7 @@ public class ProtobufSerializationServiceImplTest {
       BasicTypes.EncodingType encodingType, Object data)
       throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
     byte[] encodedValue = service.encode(encodingType, data);
-    Object decdoedValue = service.decode(encodingType, encodedValue);
-    Assert.assertEquals(data, decdoedValue);
+    Object decodedValue = service.decode(encodingType, encodedValue);
+    Assert.assertEquals(data, decodedValue);
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/test/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslatorJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslatorJUnitTest.java
index 1af710c..963cb85 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslatorJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslatorJUnitTest.java
@@ -17,6 +17,7 @@ package org.apache.geode.serialization.protobuf.translation;
 import static org.junit.Assert.assertSame;
 
 import org.apache.geode.protocol.protobuf.BasicTypes;
+import org.apache.geode.protocol.protobuf.EncodingTypeTranslator;
 import org.apache.geode.serialization.SerializationType;
 import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
 import org.apache.geode.test.junit.categories.UnitTest;

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java
index 2c37fb5..1d038f5 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java
@@ -81,17 +81,11 @@ public class CodecRegistryJUnitTest {
     Assert.assertSame(expectedCodec, codec);
   }
 
-  @Test
-  public void testGetCodecForUnregisteredType_throwsException() {
-    boolean caughtException = false;
-    try {
-      SerializationType mockSerializationType = PowerMockito.mock(SerializationType.class);
-      codecRegistry.getCodecForType(mockSerializationType);
-    } catch (CodecNotRegisteredForTypeException e) {
-      caughtException = true;
-    }
-    Assert.assertTrue("This should have thrown a CodecNotRegisteredForTypeException",
-        caughtException);
+  @Test(expected = CodecNotRegisteredForTypeException.class)
+  public void testGetCodecForUnregisteredType_throwsException()
+      throws CodecNotRegisteredForTypeException {
+    SerializationType mockSerializationType = PowerMockito.mock(SerializationType.class);
+    codecRegistry.getCodecForType(mockSerializationType);
   }
 
   class DummyTypeCodec implements TypeCodec {


[43/46] geode git commit: merge GEODE-2995, GEODE-3775 into develop with integration test.

Posted by zh...@apache.org.
merge GEODE-2995, GEODE-3775 into develop with integration test.

Signed-off-by: Brian Rowe <br...@pivotal.io>


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

Branch: refs/heads/feature/GEM-1483
Commit: db11ebc1efdf2371bdf1566a7828dc08ea621e2c
Parents: e62e825
Author: Galen OSullivan <go...@pivotal.io>
Authored: Wed Jun 21 16:53:03 2017 -0700
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Mon Jun 26 09:26:23 2017 -0700

----------------------------------------------------------------------
 .../sockets/ClientProtocolMessageHandler.java   |  18 +--
 .../tier/sockets/ServerConnectionFactory.java   |  39 +++++-
 .../sockets/ServiceLoadingFailureException.java |  35 ++++++
 .../ServerConnectionFactoryIntegrationTest.java |  67 ----------
 .../sockets/ServerConnectionFactoryTest.java    |  43 ++++++-
 .../protobuf/ProtobufStreamProcessor.java       |  15 ++-
 ...he.tier.sockets.ClientProtocolMessageHandler |   1 +
 .../RoundTripCacheConnectionJUnitTest.java      | 123 +++++++++++++++++++
 8 files changed, 256 insertions(+), 85 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/db11ebc1/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java
index 702609d..32e9e4b 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java
@@ -22,14 +22,14 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 /**
- * Stub, this will be hooked up to the new client protocol when it's implemented.
+ * This is an interface that other modules can implement to hook into
+ * {@link GenericProtocolServerConnection} to handle messages sent to Geode.
+ *
+ * Currently, only one {@link ClientProtocolMessageHandler} at a time can be used in a Geode
+ * instance. It gets wired into {@link ServerConnectionFactory} to create all instances of
+ * {@link GenericProtocolServerConnection}.
  */
-public class ClientProtocolMessageHandler {
-  /**
-   * Bogus, but it lets us write an integration test so that nobody breaks our flow.
-   */
-  public void receiveMessage(InputStream inputStream, OutputStream outputStream,
-      InternalCache cache) throws IOException {
-    outputStream.write(inputStream.read());
-  }
+public interface ClientProtocolMessageHandler {
+  void receiveMessage(InputStream inputStream, OutputStream outputStream, InternalCache cache)
+      throws IOException;
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/db11ebc1/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactory.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactory.java
index e4746a7..ad13b78 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactory.java
@@ -22,14 +22,46 @@ import org.apache.geode.internal.security.SecurityService;
 
 import java.io.IOException;
 import java.net.Socket;
+import java.util.Iterator;
+import java.util.ServiceLoader;
+import javax.management.ServiceNotFoundException;
 
 /**
  * Creates instances of ServerConnection based on the connection mode provided.
  */
 public class ServerConnectionFactory {
-  // TODO: implement ClientProtocolMessageHandler.
-  private static final ClientProtocolMessageHandler protobufProtocolHandler =
-      new ClientProtocolMessageHandler();
+  private static ClientProtocolMessageHandler protobufProtocolHandler;
+  private static final Object protocolLoadLock = new Object();
+
+  private static ClientProtocolMessageHandler findClientProtocolMessageHandler() {
+    if (protobufProtocolHandler != null) {
+      return protobufProtocolHandler;
+    }
+
+    synchronized (protocolLoadLock) {
+      if (protobufProtocolHandler != null) {
+        return protobufProtocolHandler;
+      }
+
+      ServiceLoader<ClientProtocolMessageHandler> loader =
+          ServiceLoader.load(ClientProtocolMessageHandler.class);
+      Iterator<ClientProtocolMessageHandler> iterator = loader.iterator();
+
+      if (!iterator.hasNext()) {
+        throw new ServiceLoadingFailureException(
+            "ClientProtocolMessageHandler implementation not found in JVM");
+      }
+
+      ClientProtocolMessageHandler returnValue = iterator.next();
+
+      if (iterator.hasNext()) {
+        throw new ServiceLoadingFailureException(
+            "Multiple service implementations found for ClientProtocolMessageHandler");
+      }
+
+      return returnValue;
+    }
+  }
 
   public static ServerConnection makeServerConnection(Socket s, InternalCache c,
       CachedRegionHelper helper, CacheServerStats stats, int hsTimeout, int socketBufferSize,
@@ -39,6 +71,7 @@ public class ServerConnectionFactory {
       if (!Boolean.getBoolean("geode.feature-protobuf-protocol")) {
         throw new IOException("Acceptor received unknown communication mode: " + communicationMode);
       } else {
+        protobufProtocolHandler = findClientProtocolMessageHandler();
         return new GenericProtocolServerConnection(s, c, helper, stats, hsTimeout, socketBufferSize,
             communicationModeStr, communicationMode, acceptor, protobufProtocolHandler,
             securityService);

http://git-wip-us.apache.org/repos/asf/geode/blob/db11ebc1/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServiceLoadingFailureException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServiceLoadingFailureException.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServiceLoadingFailureException.java
new file mode 100644
index 0000000..be39672
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServiceLoadingFailureException.java
@@ -0,0 +1,35 @@
+/*
+ * 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.internal.cache.tier.sockets;
+
+import org.apache.geode.GemFireException;
+
+/**
+ * Indicates that an error has happened loading a necessary service.
+ */
+public class ServiceLoadingFailureException extends GemFireException {
+  public ServiceLoadingFailureException(String message) {
+    super(message);
+  }
+
+  public ServiceLoadingFailureException(Exception cause) {
+    super(cause);
+  }
+
+  public ServiceLoadingFailureException(String message, Exception cause) {
+    super(message, cause);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/db11ebc1/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java
deleted file mode 100644
index 9a1509f..0000000
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java
+++ /dev/null
@@ -1,67 +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.internal.cache.tier.sockets;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.cache.server.CacheServer;
-import org.apache.geode.internal.AvailablePortHelper;
-import org.apache.geode.internal.cache.tier.Acceptor;
-import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.awaitility.Awaitility;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.experimental.categories.Category;
-
-import java.io.IOException;
-import java.net.Socket;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Test that switching on the header byte makes instances of
- * {@link GenericProtocolServerConnection}.
- */
-@Category(IntegrationTest.class)
-public class ServerConnectionFactoryIntegrationTest {
-
-  @Rule
-  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
-
-  @Test
-  public void testNewProtocolHeaderLeadsToNewProtocolServerConnection() throws IOException {
-    System.setProperty("geode.feature-protobuf-protocol", "true");
-
-    CacheFactory cacheFactory = new CacheFactory();
-    cacheFactory.set("mcast-port","0"); //sometimes it isn't due to other tests.
-    Cache cache = cacheFactory.create();
-
-    CacheServer cacheServer = cache.addCacheServer();
-    final int cacheServerPort = AvailablePortHelper.getRandomAvailableTCPPort();
-    cacheServer.setPort(cacheServerPort);
-    cacheServer.start();
-
-    Socket socket = new Socket("localhost", cacheServerPort);
-    Awaitility.await().atMost(5, TimeUnit.SECONDS).until(socket::isConnected);
-    socket.getOutputStream().write(Acceptor.PROTOBUF_CLIENT_SERVER_PROTOCOL);
-    socket.getOutputStream().write(222);
-    assertEquals(222, socket.getInputStream().read());
-
-    cache.close();
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/db11ebc1/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java
index 11b5289..4e994cd 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java
@@ -31,6 +31,14 @@ import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+/**
+ * We don't test the path where the service providing protobufProtocolHandler is actually present,
+ * because it lives outside this module, and all the integration tests from that module will test
+ * the newclient protocol happy path.
+ *
+ * What we are concerned with is making sure that everything stays the same when the feature flag
+ * isn't set, and that we at least try to load the service when the feature flag is true.
+ */
 @Category(UnitTest.class)
 public class ServerConnectionFactoryTest {
   /**
@@ -38,17 +46,22 @@ public class ServerConnectionFactoryTest {
    * enabled.
    */
   @Test(expected = IOException.class)
-  public void newClientProtocolThrows() throws Exception {
-    serverConnectionMockedExceptForCommunicationMode(Acceptor.PROTOBUF_CLIENT_SERVER_PROTOCOL);
+  public void newClientProtocolFailsWithoutSystemPropertySet() throws Exception {
+    ServerConnection serverConnection =
+        serverConnectionMockedExceptForCommunicationMode(Acceptor.PROTOBUF_CLIENT_SERVER_PROTOCOL);
+
   }
 
-  @Test
-  public void newClientProtocolSucceedsWithSystemPropertySet() throws Exception {
+  /**
+   * @throws ServiceLoadingFailureException because the service is implemented in a different
+   *         module, and when this unit test is run, that module won't be present.
+   */
+  @Test(expected = ServiceLoadingFailureException.class)
+  public void newClientProtocolFailsWithSystemPropertySet() throws Exception {
     try {
       System.setProperty("geode.feature-protobuf-protocol", "true");
       ServerConnection serverConnection = serverConnectionMockedExceptForCommunicationMode(
           Acceptor.PROTOBUF_CLIENT_SERVER_PROTOCOL);
-      assertTrue(serverConnection instanceof GenericProtocolServerConnection);
     } finally {
       System.clearProperty("geode.feature-protobuf-protocol");
     }
@@ -69,6 +82,26 @@ public class ServerConnectionFactoryTest {
     }
   }
 
+  @Test
+  public void makeServerConnectionForOldProtocolWithFeatureFlagEnabled() throws IOException {
+    System.setProperty("geode.feature-protobuf-protocol", "true");
+    try {
+      byte[] communicationModes =
+          new byte[] {Acceptor.CLIENT_TO_SERVER, Acceptor.PRIMARY_SERVER_TO_CLIENT,
+              Acceptor.SECONDARY_SERVER_TO_CLIENT, Acceptor.GATEWAY_TO_GATEWAY,
+              Acceptor.MONITOR_TO_SERVER, Acceptor.SUCCESSFUL_SERVER_TO_CLIENT,
+              Acceptor.UNSUCCESSFUL_SERVER_TO_CLIENT, Acceptor.CLIENT_TO_SERVER_FOR_QUEUE,};
+
+      for (byte communicationMode : communicationModes) {
+        ServerConnection serverConnection =
+            serverConnectionMockedExceptForCommunicationMode(communicationMode);
+        assertTrue(serverConnection instanceof LegacyServerConnection);
+      }
+    } finally {
+      System.clearProperty("geode.feature-protobuf-protocol");
+    }
+  }
+
   private static ServerConnection serverConnectionMockedExceptForCommunicationMode(
       byte communicationMode) throws IOException {
     Socket socketMock = mock(Socket.class);

http://git-wip-us.apache.org/repos/asf/geode/blob/db11ebc1/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufStreamProcessor.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufStreamProcessor.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufStreamProcessor.java
index 1dcb61c..d7b5d4b 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufStreamProcessor.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufStreamProcessor.java
@@ -15,6 +15,8 @@
 package org.apache.geode.protocol.protobuf;
 
 import org.apache.geode.cache.Cache;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.cache.tier.sockets.ClientProtocolMessageHandler;
 import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
 import org.apache.geode.protocol.protobuf.serializer.ProtobufProtocolSerializer;
 import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry;
@@ -34,7 +36,7 @@ import java.io.OutputStream;
  * messages, hands the requests to an appropriate handler, wraps the response in a protobuf message,
  * and then pushes it to the output stream.
  */
-public class ProtobufStreamProcessor {
+public class ProtobufStreamProcessor implements ClientProtocolMessageHandler {
   ProtobufProtocolSerializer protobufProtocolSerializer;
   OperationsHandlerRegistry registry;
   ProtobufSerializationService protobufSerializationService;
@@ -60,4 +62,15 @@ public class ProtobufStreamProcessor {
         ProtobufUtilities.wrapResponseWithDefaultHeader(response);
     protobufProtocolSerializer.serialize(responseMessage, outputStream);
   }
+
+  @Override
+  public void receiveMessage(InputStream inputStream, OutputStream outputStream,
+      InternalCache cache) throws IOException {
+    try {
+      processOneMessage(inputStream, outputStream, cache);
+    } catch (InvalidProtocolMessageException | OperationHandlerNotRegisteredException
+        | TypeEncodingException e) {
+      throw new IOException(e);
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/db11ebc1/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.internal.cache.tier.sockets.ClientProtocolMessageHandler
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.internal.cache.tier.sockets.ClientProtocolMessageHandler b/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.internal.cache.tier.sockets.ClientProtocolMessageHandler
new file mode 100644
index 0000000..5a17eda
--- /dev/null
+++ b/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.internal.cache.tier.sockets.ClientProtocolMessageHandler
@@ -0,0 +1 @@
+org.apache.geode.protocol.protobuf.ProtobufStreamProcessor
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/db11ebc1/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
new file mode 100644
index 0000000..b9faca3
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
@@ -0,0 +1,123 @@
+/*
+ * 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.protocol;
+
+import static org.junit.Assert.assertEquals;
+
+import com.google.protobuf.ByteString;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionFactory;
+import org.apache.geode.cache.server.CacheServer;
+import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.internal.cache.tier.sockets.GenericProtocolServerConnection;
+import org.apache.geode.protocol.protobuf.BasicTypes;
+import org.apache.geode.protocol.protobuf.ClientProtocol;
+import org.apache.geode.protocol.protobuf.ProtobufSerializationService;
+import org.apache.geode.protocol.protobuf.RegionAPI;
+import org.apache.geode.protocol.protobuf.serializer.ProtobufProtocolSerializer;
+import org.apache.geode.serialization.codec.StringCodec;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.awaitility.Awaitility;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
+import org.junit.experimental.categories.Category;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Test that switching on the header byte makes instances of
+ * {@link GenericProtocolServerConnection}.
+ */
+@Category(IntegrationTest.class)
+public class RoundTripCacheConnectionJUnitTest {
+  public static final String TEST_KEY = "testKey";
+  public static final String TEST_VALUE = "testValue";
+  public static final String TEST_REGION = "testRegion";
+
+  private Cache cache;
+  private int cacheServerPort;
+
+  @Rule
+  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+
+  @Before
+  public void setup() throws IOException {
+    CacheFactory cacheFactory = new CacheFactory();
+    cacheFactory.set("mcast-port", "0"); // sometimes it isn't due to other tests.
+    cache = cacheFactory.create();
+
+    CacheServer cacheServer = cache.addCacheServer();
+    cacheServerPort = AvailablePortHelper.getRandomAvailableTCPPort();
+    cacheServer.setPort(cacheServerPort);
+    cacheServer.start();
+
+    RegionFactory<Object, Object> regionFactory = cache.createRegionFactory();
+    Region<Object, Object> testRegion = regionFactory.create(TEST_REGION);
+    testRegion.put(TEST_KEY, TEST_VALUE);
+  }
+
+  @After
+  public void cleanup() {
+    cache.close();
+  }
+
+  @Test
+  public void testNewProtocolHeaderLeadsToNewProtocolServerConnection() throws Exception {
+    System.setProperty("geode.feature-protobuf-protocol", "true");
+
+    Socket socket = new Socket("localhost", cacheServerPort);
+    Awaitility.await().atMost(5, TimeUnit.SECONDS).until(socket::isConnected);
+    OutputStream outputStream = socket.getOutputStream();
+    outputStream.write(110);
+
+    ProtobufProtocolSerializer protobufProtocolSerializer = new ProtobufProtocolSerializer();
+    protobufProtocolSerializer.serialize(makeTestGetRequest(new StringCodec()), outputStream);
+
+    ClientProtocol.Message message =
+        protobufProtocolSerializer.deserialize(socket.getInputStream());
+    assertEquals(ClientProtocol.Message.MessageTypeCase.RESPONSE, message.getMessageTypeCase());
+    ClientProtocol.Response response = message.getResponse();
+    assertEquals(ClientProtocol.Response.ResponseAPICase.GETRESPONSE,
+        response.getResponseAPICase());
+    RegionAPI.GetResponse getResponse = response.getGetResponse();
+    BasicTypes.EncodedValue result = getResponse.getResult();
+    assertEquals(BasicTypes.EncodingType.STRING, result.getEncodingType());
+    assertEquals(TEST_VALUE, new ProtobufSerializationService().decode(result.getEncodingType(),
+        result.getValue().toByteArray()));
+  }
+
+  private ClientProtocol.Message makeTestGetRequest(StringCodec stringCodec) {
+    RegionAPI.GetRequest.Builder getRequestBuilder = RegionAPI.GetRequest.newBuilder();
+    getRequestBuilder.setRegionName(TEST_REGION)
+        .setKey(BasicTypes.EncodedValue.newBuilder().setEncodingType(BasicTypes.EncodingType.STRING)
+            .setValue(ByteString.copyFrom(stringCodec.encode(TEST_KEY))));
+    ClientProtocol.Request request =
+        ClientProtocol.Request.newBuilder().setGetRequest(getRequestBuilder).build();
+    ClientProtocol.Message requestMessage = ClientProtocol.Message.newBuilder()
+        .setMessageHeader(ClientProtocol.MessageHeader.newBuilder()).setRequest(request).build();
+
+    return requestMessage;
+  }
+}


[21/46] geode git commit: GEODE-3062: create new SecurityService after receiving cluster config

Posted by zh...@apache.org.
GEODE-3062: create new SecurityService after receiving cluster config


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

Branch: refs/heads/feature/GEM-1483
Commit: 6f60785c06a39b9fcc086b9a3501a82b1c049833
Parents: b7f5391
Author: Kirk Lund <kl...@apache.org>
Authored: Thu Jun 15 10:04:02 2017 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Thu Jun 22 12:39:50 2017 -0700

----------------------------------------------------------------------
 .../internal/InternalDistributedSystem.java     |  4 ++
 .../cache/ClusterConfigurationLoader.java       |  7 ++-
 .../geode/internal/cache/GemFireCacheImpl.java  | 47 ++++++++++---------
 .../security/IntegratedSecurityService.java     | 40 +++++++++-------
 .../security/LegacySecurityService.java         | 15 +-----
 .../internal/security/SecurityService.java      | 48 ++++++++++----------
 .../security/SecurityServiceFactory.java        | 10 ++--
 .../ClusterConfigDeployJarDUnitTest.java        | 11 ++---
 .../ClusterConfigDistributionDUnitTest.java     |  5 +-
 .../ClusterConfigImportDUnitTest.java           |  9 ++--
 .../ClusterConfigStartMemberDUnitTest.java      |  4 +-
 .../ClusterConfigWithSecurityDUnitTest.java     | 32 ++++++++++---
 .../test/dunit/rules/MemberStarterRule.java     | 12 ++++-
 .../test/dunit/rules/ServerStarterRule.java     | 31 +++++++++----
 14 files changed, 155 insertions(+), 120 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/6f60785c/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
index 1572355..a4b3a50 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
@@ -540,6 +540,10 @@ public class InternalDistributedSystem extends DistributedSystem
     return this.securityService;
   }
 
+  public void setSecurityService(SecurityService securityService) {
+    this.securityService = securityService;
+  }
+
   /**
    * Registers a listener to the system
    * 

http://git-wip-us.apache.org/repos/asf/geode/blob/6f60785c/geode-core/src/main/java/org/apache/geode/internal/cache/ClusterConfigurationLoader.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/ClusterConfigurationLoader.java b/geode-core/src/main/java/org/apache/geode/internal/cache/ClusterConfigurationLoader.java
index 4f4881f..92cfd96 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/ClusterConfigurationLoader.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/ClusterConfigurationLoader.java
@@ -152,13 +152,12 @@ public class ClusterConfigurationLoader {
 
   /***
    * Apply the gemfire properties cluster configuration on this member
-   *
-   * @param cache Cache created for this member
+   * 
    * @param response {@link ConfigurationResponse} containing the requested {@link Configuration}
    * @param config this member's config
    */
-  public static void applyClusterPropertiesConfiguration(Cache cache,
-      ConfigurationResponse response, DistributionConfig config) {
+  public static void applyClusterPropertiesConfiguration(ConfigurationResponse response,
+      DistributionConfig config) {
     if (response == null || response.getRequestedConfiguration().isEmpty()) {
       return;
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/6f60785c/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
index fe97685..2dda38c 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
@@ -77,6 +77,7 @@ import javax.transaction.TransactionManager;
 import com.sun.jna.Native;
 import com.sun.jna.Platform;
 import org.apache.commons.lang.StringUtils;
+import org.apache.geode.internal.security.SecurityServiceFactory;
 import org.apache.logging.log4j.Logger;
 
 import org.apache.geode.CancelCriterion;
@@ -323,6 +324,8 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
 
   private static final Pattern DOUBLE_BACKSLASH = Pattern.compile("\\\\");
 
+  private volatile ConfigurationResponse configurationResponse;
+
   /** To test MAX_QUERY_EXECUTION_TIME option. */
   public int testMaxQueryExecutionTime = -1;
 
@@ -809,7 +812,16 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
       this.system = system;
       this.dm = this.system.getDistributionManager();
 
-      this.securityService = this.system.getSecurityService();
+      this.configurationResponse = requestSharedConfiguration();
+
+      // apply the cluster's properties configuration and initialize security using that
+      // configuration
+      ClusterConfigurationLoader.applyClusterPropertiesConfiguration(this.configurationResponse,
+          this.system.getConfig());
+
+      this.securityService =
+          SecurityServiceFactory.create(this.system.getConfig().getSecurityProps(), cacheConfig);
+      this.system.setSecurityService(this.securityService);
 
       if (!this.isClient && PoolManager.getAll().isEmpty()) {
         // We only support management on members of a distributed system
@@ -1035,17 +1047,6 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
     }
   }
 
-  private void deployJarsReceivedFromClusterConfiguration(ConfigurationResponse response) {
-    try {
-      ClusterConfigurationLoader.deployJarsReceivedFromClusterConfiguration(this, response);
-    } catch (IOException | ClassNotFoundException e) {
-      throw new GemFireConfigException(
-          LocalizedStrings.GemFireCache_EXCEPTION_OCCURRED_WHILE_DEPLOYING_JARS_FROM_SHARED_CONDFIGURATION
-              .toLocalizedString(),
-          e);
-    }
-  }
-
   /**
    * When called, clusterProps and serverProps and key could not be null
    */
@@ -1150,15 +1151,18 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
       listener.cacheCreated(this);
     }
 
+    // set ClassPathLoader and then deploy cluster config jars
     ClassPathLoader.setLatestToDefault(this.system.getConfig().getDeployWorkingDir());
 
-    // request and check cluster configuration
-    ConfigurationResponse configurationResponse = requestSharedConfiguration();
-    deployJarsReceivedFromClusterConfiguration(configurationResponse);
-
-    // apply the cluster's properties configuration and initialize security using that configuration
-    ClusterConfigurationLoader.applyClusterPropertiesConfiguration(this, configurationResponse,
-        this.system.getConfig());
+    try {
+      ClusterConfigurationLoader.deployJarsReceivedFromClusterConfiguration(this,
+          this.configurationResponse);
+    } catch (IOException | ClassNotFoundException e) {
+      throw new GemFireConfigException(
+          LocalizedStrings.GemFireCache_EXCEPTION_OCCURRED_WHILE_DEPLOYING_JARS_FROM_SHARED_CONDFIGURATION
+              .toLocalizedString(),
+          e);
+    }
 
     SystemMemberCacheEventProcessor.send(this, Operation.CACHE_CREATE);
     this.resourceAdvisor.initializationGate();
@@ -1182,11 +1186,11 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
 
     boolean completedCacheXml = false;
     try {
-      if (configurationResponse == null) {
+      if (this.configurationResponse == null) {
         // Deploy all the jars from the deploy working dir.
         ClassPathLoader.getLatest().getJarDeployer().loadPreviouslyDeployedJarsFromDisk();
       }
-      ClusterConfigurationLoader.applyClusterXmlConfiguration(this, configurationResponse,
+      ClusterConfigurationLoader.applyClusterXmlConfiguration(this, this.configurationResponse,
           this.system.getConfig());
       initializeDeclarativeCache();
       completedCacheXml = true;
@@ -1199,6 +1203,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
           // I don't want init to throw an exception that came from the close.
           // I want it to throw the original exception that came from initializeDeclarativeCache.
         }
+        this.configurationResponse = null;
       }
     }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/6f60785c/geode-core/src/main/java/org/apache/geode/internal/security/IntegratedSecurityService.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/security/IntegratedSecurityService.java b/geode-core/src/main/java/org/apache/geode/internal/security/IntegratedSecurityService.java
index 171cfb7..323ab67 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/security/IntegratedSecurityService.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/security/IntegratedSecurityService.java
@@ -14,22 +14,8 @@
  */
 package org.apache.geode.internal.security;
 
-import java.io.IOException;
-import java.security.AccessController;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.Callable;
-
 import org.apache.commons.lang.SerializationException;
 import org.apache.commons.lang.StringUtils;
-import org.apache.logging.log4j.Logger;
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.ShiroException;
-import org.apache.shiro.subject.Subject;
-import org.apache.shiro.subject.support.SubjectThreadState;
-import org.apache.shiro.util.ThreadContext;
-import org.apache.shiro.util.ThreadState;
-
 import org.apache.geode.GemFireIOException;
 import org.apache.geode.internal.cache.EntryEventImpl;
 import org.apache.geode.internal.logging.LogService;
@@ -46,6 +32,20 @@ import org.apache.geode.security.ResourcePermission;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
 import org.apache.geode.security.ResourcePermission.Target;
+import org.apache.geode.security.SecurityManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.ShiroException;
+import org.apache.shiro.subject.Subject;
+import org.apache.shiro.subject.support.SubjectThreadState;
+import org.apache.shiro.util.ThreadContext;
+import org.apache.shiro.util.ThreadState;
+
+import java.io.IOException;
+import java.security.AccessController;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.Callable;
 
 /**
  * Security service with SecurityManager and an optional PostProcessor.
@@ -54,7 +54,7 @@ public class IntegratedSecurityService implements SecurityService {
   private static Logger logger = LogService.getLogger(LogService.SECURITY_LOGGER_NAME);
 
   private final PostProcessor postProcessor;
-  private final org.apache.geode.security.SecurityManager securityManager;
+  private final SecurityManager securityManager;
 
   /**
    * this creates a security service using a SecurityManager
@@ -72,11 +72,13 @@ public class IntegratedSecurityService implements SecurityService {
     this.postProcessor = postProcessor;
   }
 
+  @Override
   public PostProcessor getPostProcessor() {
     return this.postProcessor;
   }
 
-  public org.apache.geode.security.SecurityManager getSecurityManager() {
+  @Override
+  public SecurityManager getSecurityManager() {
     return this.securityManager;
   }
 
@@ -187,6 +189,7 @@ public class IntegratedSecurityService implements SecurityService {
     return threadState;
   }
 
+  @Override
   public void authorizeClusterManage() {
     authorize(Resource.CLUSTER, Operation.MANAGE, Target.ALL, ResourcePermission.ALL);
   }
@@ -266,14 +269,17 @@ public class IntegratedSecurityService implements SecurityService {
     authorize(Resource.DATA, Operation.READ, regionName, key);
   }
 
+  @Override
   public void authorize(Resource resource, Operation operation, Target target, String key) {
     authorize(resource, operation, target.getName(), key);
   }
 
+  @Override
   public void authorize(Resource resource, Operation operation, Target target) {
     authorize(resource, operation, target, ResourcePermission.ALL);
   }
 
+  @Override
   public void authorize(Resource resource, Operation operation, String target, String key) {
     authorize(new ResourcePermission(resource, operation, target, key));
   }
@@ -300,7 +306,7 @@ public class IntegratedSecurityService implements SecurityService {
   @Override
   public void close() {
     if (this.securityManager != null) {
-      securityManager.close();
+      this.securityManager.close();
     }
     if (this.postProcessor != null) {
       this.postProcessor.close();

http://git-wip-us.apache.org/repos/asf/geode/blob/6f60785c/geode-core/src/main/java/org/apache/geode/internal/security/LegacySecurityService.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/security/LegacySecurityService.java b/geode-core/src/main/java/org/apache/geode/internal/security/LegacySecurityService.java
index c594bf9..66b6876 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/security/LegacySecurityService.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/security/LegacySecurityService.java
@@ -14,17 +14,7 @@
  */
 package org.apache.geode.internal.security;
 
-import java.util.Properties;
-import java.util.concurrent.Callable;
-
 import org.apache.commons.lang.StringUtils;
-import org.apache.shiro.subject.Subject;
-import org.apache.shiro.util.ThreadState;
-
-import org.apache.geode.management.internal.security.ResourceOperation;
-import org.apache.geode.security.PostProcessor;
-import org.apache.geode.security.ResourcePermission;
-import org.apache.geode.security.SecurityManager;
 
 /**
  * implementing SecurityService when only legacy authenticators are specified
@@ -32,12 +22,11 @@ import org.apache.geode.security.SecurityManager;
 public class LegacySecurityService implements SecurityService {
 
   private final boolean hasClientAuthenticator;
-
   private final boolean hasPeerAuthenticator;
 
   LegacySecurityService() {
-    hasClientAuthenticator = false;
-    hasPeerAuthenticator = false;
+    this.hasClientAuthenticator = false;
+    this.hasPeerAuthenticator = false;
   }
 
   LegacySecurityService(final String clientAuthenticator, final String peerAuthenticator) {

http://git-wip-us.apache.org/repos/asf/geode/blob/6f60785c/geode-core/src/main/java/org/apache/geode/internal/security/SecurityService.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/security/SecurityService.java b/geode-core/src/main/java/org/apache/geode/internal/security/SecurityService.java
index feea899..b00e0f4 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/security/SecurityService.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/security/SecurityService.java
@@ -14,7 +14,6 @@
  */
 package org.apache.geode.internal.security;
 
-import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.PostProcessor;
 import org.apache.geode.security.ResourcePermission;
 import org.apache.geode.security.ResourcePermission.Resource;
@@ -28,6 +27,7 @@ import java.util.Properties;
 import java.util.concurrent.Callable;
 
 public interface SecurityService {
+
   default ThreadState bindSubject(Subject subject) {
     return null;
   }
@@ -40,57 +40,57 @@ public interface SecurityService {
     return null;
   }
 
-  default void logout() {};
+  default void logout() {}
 
   default Callable associateWith(Callable callable) {
     return callable;
   }
 
-  default void authorize(Resource resource, Operation operation, String target, String key) {};
+  default void authorize(Resource resource, Operation operation, String target, String key) {}
 
-  default void authorize(Resource resource, Operation operation, Target target, String key) {};
+  default void authorize(Resource resource, Operation operation, Target target, String key) {}
 
-  default void authorize(Resource resource, Operation operation, Target target) {};
+  default void authorize(Resource resource, Operation operation, Target target) {}
 
-  default void authorizeClusterManage() {};
+  default void authorizeClusterManage() {}
 
-  default void authorizeClusterWrite() {};
+  default void authorizeClusterWrite() {}
 
-  default void authorizeClusterRead() {};
+  default void authorizeClusterRead() {}
 
-  default void authorizeDataManage() {};
+  default void authorizeDataManage() {}
 
-  default void authorizeDataWrite() {};
+  default void authorizeDataWrite() {}
 
-  default void authorizeDataRead() {};
+  default void authorizeDataRead() {}
 
-  default void authorizeDiskManage() {};
+  default void authorizeDiskManage() {}
 
-  default void authorizeGatewayManage() {};
+  default void authorizeGatewayManage() {}
 
-  default void authorizeJarManage() {};
+  default void authorizeJarManage() {}
 
-  default void authorizeQueryManage() {};
+  default void authorizeQueryManage() {}
 
-  default void authorizeRegionManage(String regionName) {};
+  default void authorizeRegionManage(String regionName) {}
 
-  default void authorizeRegionManage(String regionName, String key) {};
+  default void authorizeRegionManage(String regionName, String key) {}
 
-  default void authorizeRegionWrite(String regionName) {};
+  default void authorizeRegionWrite(String regionName) {}
 
-  default void authorizeRegionWrite(String regionName, String key) {};
+  default void authorizeRegionWrite(String regionName, String key) {}
 
-  default void authorizeRegionRead(String regionName) {};
+  default void authorizeRegionRead(String regionName) {}
 
-  default void authorizeRegionRead(String regionName, String key) {};
+  default void authorizeRegionRead(String regionName, String key) {}
 
-  default void authorize(ResourcePermission context) {};
+  default void authorize(ResourcePermission context) {}
 
-  default void close() {};
+  default void close() {}
 
   default boolean needPostProcess() {
     return false;
-  };
+  }
 
   default Object postProcess(String regionPath, Object key, Object value,
       boolean valueIsSerialized) {

http://git-wip-us.apache.org/repos/asf/geode/blob/6f60785c/geode-core/src/main/java/org/apache/geode/internal/security/SecurityServiceFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/security/SecurityServiceFactory.java b/geode-core/src/main/java/org/apache/geode/internal/security/SecurityServiceFactory.java
index 2e0ad95..19645b6 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/security/SecurityServiceFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/security/SecurityServiceFactory.java
@@ -18,18 +18,17 @@ import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIE
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTHENTICATOR;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_SHIRO_INIT;
 
-import java.util.Properties;
-
 import org.apache.commons.lang.StringUtils;
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.UnavailableSecurityManagerException;
-
 import org.apache.geode.internal.cache.CacheConfig;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.security.shiro.SecurityManagerProvider;
 import org.apache.geode.security.PostProcessor;
 import org.apache.geode.security.SecurityManager;
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.UnavailableSecurityManagerException;
+
+import java.util.Properties;
 
 public class SecurityServiceFactory {
 
@@ -106,5 +105,4 @@ public class SecurityServiceFactory {
     }
   }
 
-
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/6f60785c/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
index 3781c98..3b105a4 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
@@ -12,13 +12,11 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-
 package org.apache.geode.management.internal.configuration;
 
 import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
-import static org.apache.geode.test.dunit.Host.getHost;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
@@ -31,11 +29,14 @@ import org.junit.experimental.categories.Category;
 
 @Category(DistributedTest.class)
 public class ClusterConfigDeployJarDUnitTest extends ClusterConfigTestBase {
+
+  private String clusterJar;
+  private String group1Jar;
+  private String group2Jar;
+
   @Rule
   public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
 
-  private String clusterJar, group1Jar, group2Jar;
-
   @Before
   public void before() throws Exception {
     clusterJar = createJarFileWithClass("Cluster", "cluster.jar", lsRule.getTempFolder().getRoot());
@@ -88,7 +89,6 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigTestBase {
     expectedClusterConfig.verify(locator3);
   }
 
-
   @Test
   public void testDeploy() throws Exception {
     // set up the locator/servers
@@ -134,7 +134,6 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigTestBase {
     expectedGroup1and2Config.verify(server3);
   }
 
-
   @Test
   public void testUndeploy() throws Exception {
     // set up the locator/servers

http://git-wip-us.apache.org/repos/asf/geode/blob/6f60785c/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
index 52a1f9b..4b003a8 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
@@ -12,7 +12,6 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-
 package org.apache.geode.management.internal.configuration;
 
 import static org.apache.commons.io.FileUtils.writeByteArrayToFile;
@@ -44,6 +43,7 @@ import java.util.Properties;
 
 @Category(DistributedTest.class)
 public class ClusterConfigDistributionDUnitTest {
+
   private static final String REPLICATE_REGION = "ReplicateRegion1";
   private static final String PARTITION_REGION = "PartitionRegion1";
   private static final String INDEX1 = "ID1";
@@ -67,7 +67,6 @@ public class ClusterConfigDistributionDUnitTest {
     lsRule.startServerVM(1, locator.getPort());
   }
 
-
   @Test
   public void testIndexAndAsyncEventQueueCommands() throws Exception {
     final String DESTROY_REGION = "regionToBeDestroyed";
@@ -88,7 +87,6 @@ public class ClusterConfigDistributionDUnitTest {
     String asyncEventQueueJarPath = createAsyncEventQueueJar();
     gfshConnector.executeAndVerifyCommand("deploy --jar=" + asyncEventQueueJarPath);
 
-
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_ASYNC_EVENT_QUEUE);
     csb.addOptionWithValueCheck(CliStrings.CREATE_ASYNC_EVENT_QUEUE__ID, AsyncEventQueue1);
     csb.addOptionWithValueCheck(CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER,
@@ -138,7 +136,6 @@ public class ClusterConfigDistributionDUnitTest {
     });
   }
 
-
   private String createAsyncEventQueueJar() throws IOException {
     String queueCommandsJarName = this.lsRule.getTempFolder().getRoot().getCanonicalPath()
         + File.separator + "testEndToEndSC-QueueCommands.jar";

http://git-wip-us.apache.org/repos/asf/geode/blob/6f60785c/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
index 521e084..066f882 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
@@ -13,7 +13,6 @@
  * the License.
  *
  */
-
 package org.apache.geode.management.internal.configuration;
 
 import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
@@ -43,13 +42,14 @@ import java.util.zip.ZipFile;
 
 @Category(DistributedTest.class)
 public class ClusterConfigImportDUnitTest extends ClusterConfigTestBase {
-  @Rule
-  public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
 
-  public static final ClusterConfig INITIAL_CONFIG = new ClusterConfig(new ConfigGroup("cluster"));
+  private static final ClusterConfig INITIAL_CONFIG = new ClusterConfig(new ConfigGroup("cluster"));
 
   private MemberVM locatorVM;
 
+  @Rule
+  public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
+
   @Before
   public void before() throws Exception {
     locatorVM = lsRule.startLocatorVM(0, locatorProps);
@@ -156,7 +156,6 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigTestBase {
   public void testExportClusterConfig(String zipFilePath) throws Exception {
     MemberVM server1 = lsRule.startServerVM(1, serverProps, locatorVM.getPort());
 
-
     gfshConnector.executeAndVerifyCommand("create region --name=myRegion --type=REPLICATE");
 
     ConfigGroup cluster = new ConfigGroup("cluster").regions("myRegion");

http://git-wip-us.apache.org/repos/asf/geode/blob/6f60785c/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
index 1cdda4c..c84a7c1 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
@@ -13,7 +13,6 @@
  * the License.
  *
  */
-
 package org.apache.geode.management.internal.configuration;
 
 import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_CONFIGURATION_DIR;
@@ -34,7 +33,8 @@ import java.util.Properties;
 
 @Category(DistributedTest.class)
 public class ClusterConfigStartMemberDUnitTest extends ClusterConfigTestBase {
-  protected MemberVM locator;
+
+  private MemberVM locator;
 
   @Before
   public void before() throws Exception {

http://git-wip-us.apache.org/repos/asf/geode/blob/6f60785c/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
index c551ca9..bb45b0d 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
@@ -12,7 +12,6 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-
 package org.apache.geode.management.internal.configuration;
 
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
@@ -24,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import org.apache.commons.io.FileUtils;
 import org.apache.geode.distributed.internal.ClusterConfigurationService;
 import org.apache.geode.distributed.internal.InternalLocator;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.configuration.utils.ZipUtils;
 import org.apache.geode.security.SimpleTestSecurityManager;
@@ -43,7 +43,10 @@ import java.util.Properties;
 
 @Category({DistributedTest.class, SecurityTest.class})
 public class ClusterConfigWithSecurityDUnitTest {
-  public String clusterConfigZipPath;
+
+  private String clusterConfigZipPath;
+  private MemberVM locator0;
+  private Properties locatorProps;
 
   @Rule
   public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
@@ -51,9 +54,6 @@ public class ClusterConfigWithSecurityDUnitTest {
   @Rule
   public GfshShellConnectionRule connector = new GfshShellConnectionRule();
 
-  MemberVM locator0;
-  Properties locatorProps;
-
   @Before
   public void before() throws Exception {
     clusterConfigZipPath = buildSecureClusterConfigZip();
@@ -64,8 +64,8 @@ public class ClusterConfigWithSecurityDUnitTest {
   }
 
   @Test
-  @Ignore("GEODE-2315")
-  public void testSecurityPropsInheritance() throws Exception {
+  @Ignore("Fails until GEODE-2315 is implemented")
+  public void testSecurityPropsInheritanceOnLocator() throws Exception {
     locatorProps.clear();
     locatorProps.setProperty(LOCATORS, "localhost[" + locator0.getPort() + "]");
     locatorProps.setProperty("security-username", "cluster");
@@ -104,6 +104,24 @@ public class ClusterConfigWithSecurityDUnitTest {
     });
   }
 
+  @Test // fails due to GEODE-3062
+  public void testSecurityPropsInheritanceOnServer() throws Exception {
+    Properties serverProps = new Properties();
+    serverProps.setProperty(LOCATORS, "localhost[" + locator0.getPort() + "]");
+    serverProps.setProperty("security-username", "cluster");
+    serverProps.setProperty("security-password", "cluster");
+    MemberVM server = lsRule.startServerVM(1, serverProps);
+
+    // cluster config specifies a security-manager so integrated security should be enabled
+    server.invoke(() -> {
+      InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
+      Properties properties = cache.getDistributedSystem().getSecurityProperties();
+      assertThat(properties.getProperty(SECURITY_MANAGER))
+          .isEqualTo(SimpleTestSecurityManager.class.getName());
+      assertThat(cache.getSecurityService().isIntegratedSecurity()).isTrue();
+    });
+  }
+
   private String buildSecureClusterConfigZip() throws Exception {
     File clusterDir = lsRule.getTempFolder().newFolder("cluster");
     File clusterSubDir = new File(clusterDir, "cluster");

http://git-wip-us.apache.org/repos/asf/geode/blob/6f60785c/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
index e5e598e..008ced7 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
@@ -27,6 +27,8 @@ import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.NAME;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
 
+import org.apache.geode.distributed.DistributedSystem;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.security.SecurityManager;
 import org.junit.rules.ExternalResource;
@@ -79,12 +81,20 @@ public abstract class MemberStarterRule<T> extends ExternalResource implements M
 
   @Override
   public void after() {
+    // invoke stopMember() first and then ds.disconnect
     stopMember();
+
+    DistributedSystem ds = InternalDistributedSystem.getConnectedInstance();
+    if (ds != null) {
+      ds.disconnect();
+    }
+
     if (oldUserDir == null) {
       System.clearProperty("user.dir");
     } else {
       System.setProperty("user.dir", oldUserDir);
     }
+
     if (temporaryFolder != null) {
       temporaryFolder.delete();
     }
@@ -116,7 +126,7 @@ public abstract class MemberStarterRule<T> extends ExternalResource implements M
     this.name = name;
     properties.setProperty(NAME, name);
     // if log-file is not already set
-    properties.putIfAbsent(LOG_FILE, new File(name + ".log").getAbsolutePath().toString());
+    properties.putIfAbsent(LOG_FILE, new File(name + ".log").getAbsolutePath());
     return (T) this;
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/6f60785c/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..6ea2d03 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
@@ -12,7 +12,6 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-
 package org.apache.geode.test.dunit.rules;
 
 import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_BIND_ADDRESS;
@@ -22,6 +21,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.START_DEV_RES
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.server.CacheServer;
+import org.apache.geode.distributed.DistributedSystem;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.internal.AvailablePortHelper;
@@ -34,7 +34,6 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 
-
 /**
  * This is a rule to start up a server in your current VM. It's useful for your Integration Tests.
  *
@@ -51,6 +50,7 @@ import java.util.Properties;
  * use {@link LocatorServerStartupRule}.
  */
 public class ServerStarterRule extends MemberStarterRule<ServerStarterRule> implements Server {
+
   private transient InternalCache cache;
   private transient CacheServer server;
   private int embeddedLocatorPort = -1;
@@ -62,7 +62,9 @@ public class ServerStarterRule extends MemberStarterRule<ServerStarterRule> impl
    * Default constructor, if used, the rule will create a temporary folder as the server's working
    * dir, and will delete it when the test is done.
    */
-  public ServerStarterRule() {}
+  public ServerStarterRule() {
+    // nothing
+  }
 
   /**
    * if constructed this way, the rule won't be deleting the workingDir after the test is done. It's
@@ -106,16 +108,26 @@ public class ServerStarterRule extends MemberStarterRule<ServerStarterRule> impl
 
   @Override
   public void stopMember() {
+    // stop CacheServer and then close cache -- cache.close() will stop any running CacheServers
+    if (server != null) {
+      try {
+        server.stop();
+      } catch (Exception e) {
+      } finally {
+        server = null;
+      }
+    }
+
     // make sure this cache is the one currently open. A server cache can be recreated due to
     // importing a new set of cluster configuration.
     cache = GemFireCacheImpl.getInstance();
     if (cache != null) {
-      cache.close();
-      cache = null;
-    }
-    if (server != null) {
-      server.stop();
-      server = null;
+      try {
+        cache.close();
+      } catch (Exception e) {
+      } finally {
+        cache = null;
+      }
     }
   }
 
@@ -125,7 +137,6 @@ public class ServerStarterRule extends MemberStarterRule<ServerStarterRule> impl
   }
 
 
-
   public ServerStarterRule withEmbeddedLocator() {
     embeddedLocatorPort = AvailablePortHelper.getRandomAvailableTCPPort();
     properties.setProperty("start-locator", "localhost[" + embeddedLocatorPort + "]");


[18/46] geode git commit: GEODE-1958: Working on removing PasswordUtil and all related commands, classes, etc. Keeping decrypt() method to maintain backwards compatibility.

Posted by zh...@apache.org.
GEODE-1958: Working on removing PasswordUtil and all related commands, classes, etc. Keeping decrypt() method to maintain backwards compatibility.

* this closes #578


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

Branch: refs/heads/feature/GEM-1483
Commit: 43b00bd84984a7c9c28536cf4a13dc104834bf0b
Parents: 5039e62
Author: YehEmily <em...@gmail.com>
Authored: Mon Jun 12 11:42:15 2017 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Wed Jun 21 11:35:47 2017 -0700

----------------------------------------------------------------------
 .../org/apache/geode/internal/SystemAdmin.java  | 167 ++++++++++---------
 .../geode/internal/i18n/LocalizedStrings.java   |   3 -
 .../geode/internal/net/SocketCreator.java       |  72 ++++----
 .../geode/internal/util/PasswordUtil.java       |  76 ++-------
 .../geode/management/internal/cli/Launcher.java |  19 +--
 .../internal/cli/commands/ShellCommands.java    |  67 ++++----
 .../internal/cli/i18n/CliStrings.java           |  11 +-
 .../geode/cache/util/PasswordUtilJUnitTest.java |  42 -----
 .../internal/util/PasswordUtilJUnitTest.java    |  41 +++++
 .../internal/security/TestCommand.java          |   3 +-
 10 files changed, 224 insertions(+), 277 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/43b00bd8/geode-core/src/main/java/org/apache/geode/internal/SystemAdmin.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/SystemAdmin.java b/geode-core/src/main/java/org/apache/geode/internal/SystemAdmin.java
index ceae486..ccc64e3 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/SystemAdmin.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/SystemAdmin.java
@@ -14,42 +14,80 @@
  */
 package org.apache.geode.internal;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+import static org.apache.geode.distributed.ConfigurationProperties.START_LOCATOR;
 
-import org.apache.geode.*;
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.RandomAccessFile;
+import java.io.StringWriter;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.net.UnknownHostException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.zip.GZIPInputStream;
+
+import org.apache.geode.GemFireException;
+import org.apache.geode.GemFireIOException;
+import org.apache.geode.InternalGemFireException;
+import org.apache.geode.NoSystemException;
+import org.apache.geode.SystemFailure;
+import org.apache.geode.UncreatedSystemException;
+import org.apache.geode.UnstartedSystemException;
 import org.apache.geode.admin.AdminException;
 import org.apache.geode.admin.BackupStatus;
 import org.apache.geode.admin.internal.AdminDistributedSystemImpl;
 import org.apache.geode.cache.persistence.PersistentID;
 import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.distributed.internal.*;
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.distributed.internal.DistributionConfigImpl;
+import org.apache.geode.distributed.internal.HighPriorityAckedMessage;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
-import org.apache.geode.distributed.internal.tcpserver.*;
-import org.apache.geode.internal.statistics.StatArchiveReader;
-import org.apache.geode.internal.statistics.StatArchiveReader.ResourceInst;
-import org.apache.geode.internal.statistics.StatArchiveReader.StatValue;
+import org.apache.geode.distributed.internal.tcpserver.TcpClient;
 import org.apache.geode.internal.admin.remote.TailLogResponse;
 import org.apache.geode.internal.cache.DiskStoreImpl;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.logging.DateFormatter;
 import org.apache.geode.internal.logging.MergeLogFiles;
 import org.apache.geode.internal.net.SocketCreator;
+import org.apache.geode.internal.statistics.StatArchiveReader;
+import org.apache.geode.internal.statistics.StatArchiveReader.ResourceInst;
+import org.apache.geode.internal.statistics.StatArchiveReader.StatValue;
 import org.apache.geode.internal.util.JavaCommandBuilder;
-import org.apache.geode.internal.util.PasswordUtil;
 import org.apache.geode.internal.util.PluckStacks;
 import org.apache.geode.internal.util.PluckStacks.ThreadStack;
 
-import java.io.*;
-import java.net.*;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.zip.GZIPInputStream;
-
-import static org.apache.geode.distributed.ConfigurationProperties.START_LOCATOR;
-
 /**
  * Provides static methods for various system administation tasks.
  */
@@ -163,7 +201,7 @@ public class SystemAdmin {
             String msg = tailFile(logFile, false);
             throw new GemFireIOException(
                 LocalizedStrings.SystemAdmin_START_OF_LOCATOR_FAILED_THE_END_OF_0_CONTAINED_THIS_MESSAGE_1
-                    .toLocalizedString(new Object[] {logFile, msg}),
+                    .toLocalizedString(logFile, msg),
                 null);
           } catch (IOException ignore) {
             throw new GemFireIOException(
@@ -335,13 +373,11 @@ public class SystemAdmin {
       ManagerInfo mi = ManagerInfo.loadLocatorInfo(directory);
       if (statusCode == ManagerInfo.KILLED_STATUS_CODE) {
         return LocalizedStrings.SystemAdmin_LOCATOR_IN_0_WAS_KILLED_WHILE_IT_WAS_1_LOCATOR_PROCESS_ID_WAS_2
-            .toLocalizedString(
-                new Object[] {directory, ManagerInfo.statusToString(mi.getManagerStatus()),
-                    Integer.valueOf(mi.getManagerProcessId())});
+            .toLocalizedString(directory, ManagerInfo.statusToString(mi.getManagerStatus()),
+                Integer.valueOf(mi.getManagerProcessId()));
       } else {
         return LocalizedStrings.SystemAdmin_LOCATOR_IN_0_IS_1_LOCATOR_PROCESS_ID_IS_2
-            .toLocalizedString(
-                new Object[] {directory, statusString, Integer.valueOf(mi.getManagerProcessId())});
+            .toLocalizedString(directory, statusString, Integer.valueOf(mi.getManagerProcessId()));
       }
     } catch (UnstartedSystemException ex) {
       return LocalizedStrings.SystemAdmin_LOCATOR_IN_0_IS_STOPPED.toLocalizedString(directory);
@@ -535,7 +571,7 @@ public class SystemAdmin {
       File outputFile = null;
 
       if (cmdLine.size() > 0) {
-        outputFile = new File((String) cmdLine.get(0));
+        outputFile = new File(cmdLine.get(0));
         os = new FileOutputStream(outputFile);
         ps = new PrintWriter(os);
       } else {
@@ -627,7 +663,7 @@ public class SystemAdmin {
   }
 
   public static void showDiskStoreMetadata(ArrayList<String> args) {
-    String dsName = (String) args.get(0);
+    String dsName = args.get(0);
     File[] dirs = argsToFile(args.subList(1, args.size()));
 
     try {
@@ -643,7 +679,7 @@ public class SystemAdmin {
       out.mkdirs();
     }
 
-    String dsName = (String) args.get(0);
+    String dsName = args.get(0);
     File[] dirs = argsToFile(args.subList(1, args.size()));
 
     try {
@@ -757,7 +793,7 @@ public class SystemAdmin {
       } catch (FileNotFoundException ex) {
         throw new GemFireIOException(
             LocalizedStrings.SystemAdmin_COULD_NOT_CREATE_FILE_0_FOR_OUTPUT_BECAUSE_1
-                .toLocalizedString(new Object[] {outOption, getExceptionMessage(ex)}));
+                .toLocalizedString(outOption, getExceptionMessage(ex)));
       }
     } else {
       ps = System.out;
@@ -778,7 +814,7 @@ public class SystemAdmin {
       } catch (FileNotFoundException ex) {
         throw new GemFireIOException(
             LocalizedStrings.SystemAdmin_COULD_NOT_OPEN_TO_0_FOR_READING_BECAUSE_1
-                .toLocalizedString(new Object[] {fileName, getExceptionMessage(ex)}));
+                .toLocalizedString(fileName, getExceptionMessage(ex)));
       }
       if (!quiet) {
         ps.println("  " + fileName);
@@ -1312,7 +1348,7 @@ public class SystemAdmin {
               .toLocalizedString(
                   new Object[] {"commands", "options", "usage", "configuration", "-h"}));
     } else if (topic.equalsIgnoreCase("commands")) {
-      pw.println((String) usageMap.get("gemfire") + " <command> ...");
+      pw.println(usageMap.get("gemfire") + " <command> ...");
       format(pw, (String) helpMap.get("gemfire"), "  ", 0);
       for (int i = 0; i < validCommands.length; i++) {
         pw.println((String) usageMap.get(validCommands[i]));
@@ -1385,10 +1421,10 @@ public class SystemAdmin {
 
   private final static String[] validCommands = new String[] {"version", "stats", START_LOCATOR,
       "stop-locator", "status-locator", "info-locator", "tail-locator-log", "merge-logs",
-      "encrypt-password", "revoke-missing-disk-store", "list-missing-disk-stores",
-      "validate-disk-store", "upgrade-disk-store", "compact-disk-store", "compact-all-disk-stores",
-      "modify-disk-store", "show-disk-store-metadata", "export-disk-store", "shut-down-all",
-      "backup", "print-stacks", "help"};
+      "revoke-missing-disk-store", "list-missing-disk-stores", "validate-disk-store",
+      "upgrade-disk-store", "compact-disk-store", "compact-all-disk-stores", "modify-disk-store",
+      "show-disk-store-metadata", "export-disk-store", "shut-down-all", "backup", "print-stacks",
+      "help"};
 
   protected static String[] getValidCommands() {
     return validCommands.clone();
@@ -1475,28 +1511,23 @@ public class SystemAdmin {
   protected final Map helpMap = new HashMap();
 
   protected void initHelpMap() {
-    helpMap.put("gemfire", LocalizedStrings.SystemAdmin_GEMFIRE_HELP.toLocalizedString(
-        new Object[] {join(validCommands), "-h", "-debug", "-help", "-q", "-J<vmOpt>"}));
+    helpMap.put("gemfire", LocalizedStrings.SystemAdmin_GEMFIRE_HELP
+        .toLocalizedString(join(validCommands), "-h", "-debug", "-help", "-q", "-J<vmOpt>"));
     helpMap.put("version", LocalizedStrings.SystemAdmin_VERSION_HELP.toLocalizedString());
     helpMap.put("help", LocalizedStrings.SystemAdmin_HELP_HELP.toLocalizedString());
     helpMap.put("stats",
-        LocalizedStrings.SystemAdmin_STATS_HELP_PART_A.toLocalizedString(new Object[] {"+",
-            "++", ":", ".", "-details", "-nofilter", "-archive=", "-persec", "-persample",
-            "-prunezeros"}) + "\n"
-            + LocalizedStrings.SystemAdmin_STATS_HELP_PART_B.toLocalizedString(new Object[] {
-                "-starttime", "-archive=", DateFormatter.FORMAT_STRING, "-endtime",}));
-    helpMap.put("encrypt-password",
-        LocalizedStrings.SystemAdmin_ENCRYPTS_A_PASSWORD_FOR_USE_IN_CACHE_XML_DATA_SOURCE_CONFIGURATION
-            .toLocalizedString());
+        LocalizedStrings.SystemAdmin_STATS_HELP_PART_A.toLocalizedString("+", "++", ":", ".",
+            "-details", "-nofilter", "-archive=", "-persec", "-persample", "-prunezeros") + "\n"
+            + LocalizedStrings.SystemAdmin_STATS_HELP_PART_B.toLocalizedString("-starttime",
+                "-archive=", DateFormatter.FORMAT_STRING, "-endtime"));
     helpMap.put(START_LOCATOR,
-        LocalizedStrings.SystemAdmin_START_LOCATOR_HELP.toLocalizedString(new Object[] {"-port=",
+        LocalizedStrings.SystemAdmin_START_LOCATOR_HELP.toLocalizedString("-port=",
             Integer.valueOf(DistributionLocator.DEFAULT_LOCATOR_PORT), "-address=", "-dir=",
-            "-properties=", "-peer=", "-server=", "-hostname-for-clients=", "-D", "-X"}));
-    helpMap.put("stop-locator",
-        LocalizedStrings.SystemAdmin_STOP_LOCATOR_HELP.toLocalizedString(new Object[] {"-port=",
-            Integer.valueOf(DistributionLocator.DEFAULT_LOCATOR_PORT), "-address=", "-dir="}));
+            "-properties=", "-peer=", "-server=", "-hostname-for-clients=", "-D", "-X"));
+    helpMap.put("stop-locator", LocalizedStrings.SystemAdmin_STOP_LOCATOR_HELP.toLocalizedString(
+        "-port=", Integer.valueOf(DistributionLocator.DEFAULT_LOCATOR_PORT), "-address=", "-dir="));
     helpMap.put("status-locator", LocalizedStrings.SystemAdmin_STATUS_LOCATOR_HELP
-        .toLocalizedString(new Object[] {join(ManagerInfo.statusNames), "-dir="}));
+        .toLocalizedString(join(ManagerInfo.statusNames), "-dir="));
     helpMap.put("info-locator",
         LocalizedStrings.SystemAdmin_INFO_LOCATOR_HELP.toLocalizedString("-dir="));
     helpMap.put("tail-locator-log",
@@ -1593,15 +1624,15 @@ public class SystemAdmin {
             .toLocalizedString());
     helpMap.put("-starttime=",
         LocalizedStrings.SystemAdmin_CAUSES_THE_0_COMMAND_TO_IGNORE_STATISTICS_SAMPLES_TAKEN_BEFORE_THIS_TIME_THE_ARGUMENT_FORMAT_MUST_MATCH_1
-            .toLocalizedString(new Object[] {"stats", DateFormatter.FORMAT_STRING}));
+            .toLocalizedString("stats", DateFormatter.FORMAT_STRING));
     helpMap.put("-endtime=",
         LocalizedStrings.SystemAdmin_CAUSES_THE_0_COMMAND_TO_IGNORE_STATISTICS_SAMPLES_TAKEN_AFTER_THIS_TIME_THE_ARGUMENT_FORMAT_MUST_MATCH_1
-            .toLocalizedString(new Object[] {"stats", DateFormatter.FORMAT_STRING}));
+            .toLocalizedString("stats", DateFormatter.FORMAT_STRING));
     helpMap.put("-dir=",
-        LocalizedStrings.SystemAdmin_DIR_ARGUMENT_HELP
-            .toLocalizedString(new Object[] {DistributionConfig.GEMFIRE_PREFIX + "properties",
-                DistributionConfig.GEMFIRE_PREFIX + "systemDirectory", "GEMFIRE", "defaultSystem",
-                "version"}));
+        LocalizedStrings.SystemAdmin_DIR_ARGUMENT_HELP.toLocalizedString(
+            DistributionConfig.GEMFIRE_PREFIX + "properties",
+            DistributionConfig.GEMFIRE_PREFIX + "systemDirectory", "GEMFIRE", "defaultSystem",
+            "version"));
     helpMap.put("-D",
         LocalizedStrings.SystemAdmin_SETS_A_JAVA_SYSTEM_PROPERTY_IN_THE_LOCATOR_VM_USED_MOST_OFTEN_FOR_CONFIGURING_SSL_COMMUNICATION
             .toLocalizedString());
@@ -1649,7 +1680,6 @@ public class SystemAdmin {
     usageMap.put("info-locator", "info-locator [-dir=<locatorDir>]");
     usageMap.put("tail-locator-log", "tail-locator-log [-dir=<locatorDir>]");
     usageMap.put("merge-logs", "merge-logs <logFile>+ [-out=<outFile>]");
-    usageMap.put("encrypt-password", "encrypt-password <passwordString>");
     usageMap.put("validate-disk-store", "validate-disk-store <diskStoreName> <directory>+");
     usageMap.put("upgrade-disk-store",
         "upgrade-disk-store <diskStoreName> <directory>+ [-maxOplogSize=<int>]");
@@ -1733,7 +1763,6 @@ public class SystemAdmin {
     cmdOptionsMap.put("export-disk-store", new String[] {"-outputDir="});
     cmdOptionsMap.put("shut-down-all", new String[] {});
     cmdOptionsMap.put("backup", new String[] {"-baseline="});
-    cmdOptionsMap.put("encrypt-password", new String[] {});
     cmdOptionsMap.put("print-stacks", new String[] {"-all-threads"});
   }
 
@@ -1900,19 +1929,8 @@ public class SystemAdmin {
   }
 
   private static boolean needsSysDir(String cmd) {
-    if (cmd.equalsIgnoreCase("stats")) {
-      return false;
-    }
-    if (cmd.equalsIgnoreCase("merge-logs")) {
-      return false;
-    }
-    if (cmd.equalsIgnoreCase("version")) {
-      return false;
-    }
-    if (cmd.equalsIgnoreCase("help")) {
-      return false;
-    }
-    return true;
+    return !(cmd.equalsIgnoreCase("stats") || cmd.equalsIgnoreCase("merge-logs")
+        || cmd.equalsIgnoreCase("version") || cmd.equalsIgnoreCase("help"));
   }
 
   public static File getProductDir() {
@@ -2206,11 +2224,6 @@ public class SystemAdmin {
           usage(cmd);
         }
         backup((String) cmdLine.get(0));
-      } else if (cmd.equalsIgnoreCase("encrypt-password")) {
-        if (cmdLine.size() != 1) {
-          usage(cmd);
-        }
-        PasswordUtil.encrypt((String) cmdLine.get(0));
       } else if (cmd.equalsIgnoreCase("print-stacks")) {
         printStacks(cmdLine, printStacksOption != null);
       } else {

http://git-wip-us.apache.org/repos/asf/geode/blob/43b00bd8/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java b/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
index ae1c005..baad039 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
@@ -4514,8 +4514,6 @@ public class LocalizedStrings {
       "Prints statistic values from a statistic archive\nBy default all statistics are printed.\nThe statSpec arguments can be used to print individual resources or a specific statistic.\nThe format of a statSpec is: an optional combine operator, followed by an optional instanceId, followed by an optional typeId, followed by an optional statId.\nA combine operator can be \"{0}\" to combine all matches in the same file, or \"{1}\" to combine all matches across all files.\nAn instanceId must be the name or id of a resource.\nA typeId is a \"{2}\" followed by the name of a resource type.\nA statId is a \"{3}\" followed by the name of a statistic.\nA typeId or instanceId with no statId prints out all the matching resources and all their statistics.\nA typeId or instanceId with a statId prints out just the named statistic on the matching resources.\nA statId with no typeId or instanceId matches all statistics with that name.\nThe \"{4}\" option causes statistic descriptions to also be pr
 inted.\nThe \"{5}\" option, in conjunction with \"{6}\", causes the printed statistics to all be raw, unfiltered, values.\nThe \"{7}\" option, in conjunction with \"{6}\", causes the printed statistics to be the rate of change, per second, of the raw values.\nThe \"{8}\" option, in conjunction with \"{6}\", causes the printed statistics to be the rate of change, per sample, of the raw values.\nThe \"{9}\" option, in conjunction with \"{6}\", causes statistics whose values are all zero to not be printed.");
   public static final StringId SystemAdmin_STATS_HELP_PART_B = new StringId(3751,
       "The \"{0}\" option, in conjunction with \"{1}\", causes statistics samples taken before this time to be ignored. The argument format must match \"{2}\".\nThe \"{3}\" option, in conjunction with \"{1}\", causes statistics samples taken after this time to be ignored. The argument format must match \"{2}\".\nThe \"{1}\" option causes the data to come from an archive file.");
-  public static final StringId SystemAdmin_ENCRYPTS_A_PASSWORD_FOR_USE_IN_CACHE_XML_DATA_SOURCE_CONFIGURATION =
-      new StringId(3752, "Encrypts a password for use in cache.xml data source configuration.");
   public static final StringId SystemAdmin_START_LOCATOR_HELP = new StringId(3753,
       "Starts a locator.\nThe \"{0}\" option specifies the port the locator will listen on. It defaults to \"{1}\"\nThe \"{2}\" option specifies the address the locator will listen on. It defaults to listening on all local addresses.\nThe \"{3}\" option can be used to specify the directory the locator will run in.\nThe \"{4}\" option can be used to specify the gemfire.properties file for configuring the locator''s distributed system.  The file''s path should be absolute, or relative to the locator''s directory ({3})\nThe \"{5}\" option can be used to specify whether peer locator service should be enabled. True (the default) will enable the service.\nThe \"{6}\" option can be used to specify whether server locator service should be enabled. True (the default) will enable the service.\nThe \"{7}\" option can be used to specify a host name or ip address that will be sent to clients so they can connect to this locator. The default is to use the address the locator is listening on.\nThe 
 \"{8}\" option can be used to set system properties for the locator VM\nThe \"{9}\" option can be used to set vendor-specific VM options and is usually used to increase the size of the locator VM when using multicast.\n");
   public static final StringId SystemAdmin_STOP_LOCATOR_HELP = new StringId(3754,
@@ -4960,7 +4958,6 @@ public class LocalizedStrings {
       new StringId(3979, "Pooled High Priority Message Processor ");
   public static final StringId DistributionManager_POOLED_WAITING_MESSAGE_PROCESSOR =
       new StringId(3980, "Pooled Waiting Message Processor ");
-  public static final StringId PasswordUtil_ENCRYPTED_TO_0 = new StringId(3981, "Encrypted to {0}");
   public static final StringId DistributionManager_SHUTDOWN_MESSAGE_THREAD_FOR_0 =
       new StringId(3982, "Shutdown Message Thread for {0}");
   public static final StringId HealthMonitorImpl_HEALTH_MONITOR_OWNED_BY_0 =

http://git-wip-us.apache.org/repos/asf/geode/blob/43b00bd8/geode-core/src/main/java/org/apache/geode/internal/net/SocketCreator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/net/SocketCreator.java b/geode-core/src/main/java/org/apache/geode/internal/net/SocketCreator.java
index fec81ca..844b484 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/net/SocketCreator.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/net/SocketCreator.java
@@ -14,32 +14,6 @@
  */
 package org.apache.geode.internal.net;
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.geode.GemFireConfigException;
-import org.apache.geode.SystemConnectException;
-import org.apache.geode.SystemFailure;
-import org.apache.geode.admin.internal.InetAddressUtil;
-import org.apache.geode.cache.wan.GatewaySender;
-import org.apache.geode.cache.wan.GatewayTransportFilter;
-import org.apache.geode.distributed.ClientSocketFactory;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.distributed.internal.DistributionConfigImpl;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.internal.ClassPathLoader;
-import org.apache.geode.internal.ConnectionWatcher;
-import org.apache.geode.internal.GfeConsoleReaderFactory;
-import org.apache.geode.internal.GfeConsoleReaderFactory.GfeConsoleReader;
-import org.apache.geode.internal.admin.SSLConfig;
-import org.apache.geode.internal.cache.wan.TransportFilterServerSocket;
-import org.apache.geode.internal.cache.wan.TransportFilterSocketFactory;
-import org.apache.geode.internal.i18n.LocalizedStrings;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.internal.logging.log4j.LocalizedMessage;
-import org.apache.geode.internal.security.SecurableCommunicationChannel;
-import org.apache.geode.internal.util.ArgumentRedactor;
-import org.apache.geode.internal.util.PasswordUtil;
-import org.apache.logging.log4j.Logger;
-
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.net.BindException;
@@ -75,6 +49,7 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Random;
 import java.util.Set;
+
 import javax.naming.Context;
 import javax.naming.NamingEnumeration;
 import javax.naming.directory.Attribute;
@@ -97,6 +72,33 @@ import javax.net.ssl.TrustManager;
 import javax.net.ssl.TrustManagerFactory;
 import javax.net.ssl.X509ExtendedKeyManager;
 
+import org.apache.commons.lang.StringUtils;
+import org.apache.logging.log4j.Logger;
+
+import org.apache.geode.GemFireConfigException;
+import org.apache.geode.SystemConnectException;
+import org.apache.geode.SystemFailure;
+import org.apache.geode.admin.internal.InetAddressUtil;
+import org.apache.geode.cache.wan.GatewaySender;
+import org.apache.geode.cache.wan.GatewayTransportFilter;
+import org.apache.geode.distributed.ClientSocketFactory;
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.distributed.internal.DistributionConfigImpl;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.internal.ClassPathLoader;
+import org.apache.geode.internal.ConnectionWatcher;
+import org.apache.geode.internal.GfeConsoleReaderFactory;
+import org.apache.geode.internal.GfeConsoleReaderFactory.GfeConsoleReader;
+import org.apache.geode.internal.admin.SSLConfig;
+import org.apache.geode.internal.cache.wan.TransportFilterServerSocket;
+import org.apache.geode.internal.cache.wan.TransportFilterSocketFactory;
+import org.apache.geode.internal.i18n.LocalizedStrings;
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.internal.logging.log4j.LocalizedMessage;
+import org.apache.geode.internal.security.SecurableCommunicationChannel;
+import org.apache.geode.internal.util.ArgumentRedactor;
+import org.apache.geode.internal.util.PasswordUtil;
+
 /**
  * Analyze configuration data (gemfire.properties) and configure sockets accordingly for SSL.
  * <p>
@@ -294,7 +296,7 @@ public class SocketCreator {
    * hits and duplicate strings
    */
   public static synchronized String getHostName(InetAddress addr) {
-    String result = (String) hostNames.get(addr);
+    String result = hostNames.get(addr);
     if (result == null) {
       result = addr.getHostName();
       hostNames.put(addr, result);
@@ -307,7 +309,7 @@ public class SocketCreator {
    * hits and duplicate strings
    */
   public static synchronized String getCanonicalHostName(InetAddress addr, String hostName) {
-    String result = (String) hostNames.get(addr);
+    String result = hostNames.get(addr);
     if (result == null) {
       hostNames.put(addr, hostName);
       return hostName;
@@ -434,14 +436,8 @@ public class SocketCreator {
             throw new GemFireConfigException(
                 "SSL properties are empty, but a console is not available");
           }
-          if (key.toLowerCase().contains("password")) {
-            char[] password = consoleReader.readPassword("Please enter " + key + ": ");
-            env.put(key, PasswordUtil.encrypt(new String(password), false));
-          } else {
-            String val = consoleReader.readLine("Please enter " + key + ": ");
-            env.put(key, val);
-          }
-
+          String val = consoleReader.readLine("Please enter " + key + ": ");
+          env.put(key, val);
         }
       }
     }
@@ -727,7 +723,7 @@ public class SocketCreator {
       } catch (BindException e) {
         BindException throwMe =
             new BindException(LocalizedStrings.SocketCreator_FAILED_TO_CREATE_SERVER_SOCKET_ON_0_1
-                .toLocalizedString(new Object[] {bindAddr, Integer.valueOf(nport)}));
+                .toLocalizedString(bindAddr, Integer.valueOf(nport)));
         throwMe.initCause(e);
         throw throwMe;
       }
@@ -784,7 +780,7 @@ public class SocketCreator {
       } catch (BindException e) {
         BindException throwMe =
             new BindException(LocalizedStrings.SocketCreator_FAILED_TO_CREATE_SERVER_SOCKET_ON_0_1
-                .toLocalizedString(new Object[] {bindAddr, Integer.valueOf(nport)}));
+                .toLocalizedString(bindAddr, Integer.valueOf(nport)));
         throwMe.initCause(e);
         throw throwMe;
       }

http://git-wip-us.apache.org/repos/asf/geode/blob/43b00bd8/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java b/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
index b3472c7..5cc3bcd 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
@@ -14,8 +14,6 @@
  */
 package org.apache.geode.internal.util;
 
-import org.apache.geode.internal.i18n.LocalizedStrings;
-
 import javax.crypto.Cipher;
 import javax.crypto.spec.SecretKeySpec;
 
@@ -44,72 +42,30 @@ public class PasswordUtil {
   private static byte[] init = "string".getBytes();
 
   /**
-   * Encrypts a password string
-   * 
-   * @param password String to be encrypted.
-   * @return String encrypted String
-   */
-  public static String encrypt(String password) {
-    return encrypt(password, true);
-  }
-
-  /**
-   * 
-   * @param password String to be encrypted
-   * @param echo if true prints result to system.out
-   * @return String encrypted String
-   */
-  public static String encrypt(String password, boolean echo) {
-    String encryptedString = null;
-    try {
-      SecretKeySpec key = new SecretKeySpec(init, "Blowfish");
-      Cipher cipher = Cipher.getInstance("Blowfish");
-      cipher.init(Cipher.ENCRYPT_MODE, key);
-      byte[] encrypted = cipher.doFinal(password.getBytes());
-      encryptedString = byteArrayToHexString(encrypted);
-      if (echo) {
-        System.out.println(
-            LocalizedStrings.PasswordUtil_ENCRYPTED_TO_0.toLocalizedString(encryptedString));
-      }
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
-    return encryptedString;
-  }
-
-  /**
    * Decrypts an encrypted password string.
-   * 
+   *
    * @param password String to be decrypted
    * @return String decrypted String
    */
+  @Deprecated
   public static String decrypt(String password) {
+    String toDecrypt;
     if (password.startsWith("encrypted(") && password.endsWith(")")) {
-      byte[] decrypted = null;
-      try {
-        String toDecrypt = password.substring(10, password.length() - 1);
-        SecretKeySpec key = new SecretKeySpec(init, "Blowfish");
-        Cipher cipher = Cipher.getInstance("Blowfish");
-        cipher.init(Cipher.DECRYPT_MODE, key);
-        decrypted = cipher.doFinal(hexStringToByteArray(toDecrypt));
-        return new String(decrypted);
-      } catch (Exception e) {
-        e.printStackTrace();
-      }
+      toDecrypt = password.substring(10, password.length() - 1);
+    } else {
+      toDecrypt = password;
     }
-    return password;
-  }
-
-  private static String byteArrayToHexString(byte[] b) {
-    StringBuilder sb = new StringBuilder(b.length * 2);
-    for (int i = 0; i < b.length; i++) {
-      int v = b[i] & 0xff;
-      if (v < 16) {
-        sb.append('0');
-      }
-      sb.append(Integer.toHexString(v));
+    byte[] decrypted;
+    try {
+      SecretKeySpec key = new SecretKeySpec(init, "Blowfish");
+      Cipher cipher = Cipher.getInstance("Blowfish");
+      cipher.init(Cipher.DECRYPT_MODE, key);
+      decrypted = cipher.doFinal(hexStringToByteArray(toDecrypt));
+      return new String(decrypted);
+    } catch (Exception e) {
+      e.printStackTrace();
     }
-    return sb.toString().toUpperCase();
+    return toDecrypt;
   }
 
   private static byte[] hexStringToByteArray(String s) {

http://git-wip-us.apache.org/repos/asf/geode/blob/43b00bd8/geode-core/src/main/java/org/apache/geode/management/internal/cli/Launcher.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/Launcher.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/Launcher.java
index e4e00da..a5986f5 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/Launcher.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/Launcher.java
@@ -14,22 +14,23 @@
  */
 package org.apache.geode.management.internal.cli;
 
-import org.apache.geode.internal.GemFireVersion;
-import org.apache.geode.internal.PureJavaMode;
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.shell.Gfsh;
-import org.apache.geode.management.internal.cli.shell.GfshConfig;
-import org.apache.geode.management.internal.cli.shell.jline.GfshHistory;
-import org.springframework.shell.core.ExitShellRequest;
-
 import java.io.IOException;
 import java.io.PrintStream;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+
 import joptsimple.OptionException;
 import joptsimple.OptionParser;
 import joptsimple.OptionSet;
+import org.springframework.shell.core.ExitShellRequest;
+
+import org.apache.geode.internal.GemFireVersion;
+import org.apache.geode.internal.PureJavaMode;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.shell.Gfsh;
+import org.apache.geode.management.internal.cli.shell.GfshConfig;
+import org.apache.geode.management.internal.cli.shell.jline.GfshHistory;
 
 /**
  * Launcher class for :
@@ -93,8 +94,6 @@ public class Launcher {
   protected Launcher() {
     this.startupTimeLogHelper = new StartupTimeLogHelper();
     this.allowedCommandLineCommands = new HashSet<String>();
-
-    this.allowedCommandLineCommands.add(CliStrings.ENCRYPT);
     this.allowedCommandLineCommands.add(CliStrings.RUN);
     this.allowedCommandLineCommands.add(CliStrings.START_PULSE);
     this.allowedCommandLineCommands.add(CliStrings.START_JCONSOLE);

http://git-wip-us.apache.org/repos/asf/geode/blob/43b00bd8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java
index e37d1ba..2da95a7 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShellCommands.java
@@ -20,7 +20,38 @@ import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_P
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Writer;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.KeyStore;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManagerFactory;
+
 import org.apache.commons.lang.StringUtils;
+import org.springframework.shell.core.ExitShellRequest;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.internal.ClassPathLoader;
 import org.apache.geode.internal.DSFIDFactory;
@@ -54,35 +85,6 @@ import org.apache.geode.management.internal.web.http.support.SimpleHttpRequester
 import org.apache.geode.management.internal.web.shell.HttpOperationInvoker;
 import org.apache.geode.management.internal.web.shell.RestHttpOperationInvoker;
 import org.apache.geode.security.AuthenticationFailedException;
-import org.springframework.shell.core.ExitShellRequest;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Writer;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.KeyStore;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.Set;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManagerFactory;
 
 /**
  *
@@ -985,13 +987,6 @@ public class ShellCommands implements GfshCommand {
     return result;
   }
 
-  @CliCommand(value = CliStrings.ENCRYPT, help = CliStrings.ENCRYPT__HELP)
-  @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GEODE_DEBUG_UTIL})
-  public Result encryptPassword(@CliOption(key = CliStrings.ENCRYPT_STRING,
-      help = CliStrings.ENCRYPT_STRING__HELP, mandatory = true) String stringToEncrypt) {
-    return ResultBuilder.createInfoResult(PasswordUtil.encrypt(stringToEncrypt, false/* echo */));
-  }
-
   @CliCommand(value = {CliStrings.VERSION}, help = CliStrings.VERSION__HELP)
   @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GFSH})
   public Result version(@CliOption(key = {CliStrings.VERSION__FULL}, specifiedDefaultValue = "true",

http://git-wip-us.apache.org/repos/asf/geode/blob/43b00bd8/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
index bdf5cff..0f74edd 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
@@ -36,6 +36,8 @@ import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_ARC
 import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_SAMPLE_RATE;
 import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION;
 
+import java.text.MessageFormat;
+
 import org.apache.geode.cache.PartitionAttributesFactory;
 import org.apache.geode.cache.server.CacheServer;
 import org.apache.geode.distributed.ConfigurationProperties;
@@ -44,8 +46,6 @@ import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.internal.cache.xmlcache.CacheXml;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
 
-import java.text.MessageFormat;
-
 /**
  * - * Contains 'String' constants used as key to the Localized strings to be used in classes under
  * <code>org.apache.geode.management.internal.cli</code> for Command Line Interface (CLI). NOTES: 1.
@@ -1265,13 +1265,6 @@ public class CliStrings {
       "String to be echoed. For example, \"SYS_USER variable is set to ${SYS_USER}\".";
   public static final String ECHO__MSG__NO_GFSH_INSTANCE = "Could not get GFSH Instance";
 
-  /* 'encrypt password' command */
-  public static final String ENCRYPT = "encrypt password";
-  public static final String ENCRYPT__HELP =
-      "Encrypt a password for use in data source configuration.";
-  public static final String ENCRYPT_STRING = "password";
-  public static final String ENCRYPT_STRING__HELP = "Password to be encrypted.";
-
   /* 'execute function' command */
   public static final String EXECUTE_FUNCTION = "execute function";
   public static final String EXECUTE_FUNCTION__HELP =

http://git-wip-us.apache.org/repos/asf/geode/blob/43b00bd8/geode-core/src/test/java/org/apache/geode/cache/util/PasswordUtilJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/util/PasswordUtilJUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/util/PasswordUtilJUnitTest.java
deleted file mode 100644
index 06e8666..0000000
--- a/geode-core/src/test/java/org/apache/geode/cache/util/PasswordUtilJUnitTest.java
+++ /dev/null
@@ -1,42 +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.cache.util;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.internal.util.PasswordUtil;
-import org.apache.geode.test.junit.categories.SecurityTest;
-import org.apache.geode.test.junit.categories.UnitTest;
-
-@Category({UnitTest.class, SecurityTest.class})
-public class PasswordUtilJUnitTest {
-
-  @Test
-  public void testPasswordUtil() {
-    String x = "password";
-    String z = null;
-
-    // System.out.println(x);
-    String y = PasswordUtil.encrypt(x);
-    // System.out.println(y);
-    y = "encrypted(" + y + ")";
-    z = PasswordUtil.decrypt(y);
-    // System.out.println(z);
-    assertEquals(x, z);
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/43b00bd8/geode-core/src/test/java/org/apache/geode/internal/util/PasswordUtilJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/util/PasswordUtilJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/util/PasswordUtilJUnitTest.java
new file mode 100644
index 0000000..8051c56
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/util/PasswordUtilJUnitTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.internal.util;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.test.junit.categories.SecurityTest;
+import org.apache.geode.test.junit.categories.UnitTest;
+
+@Category({UnitTest.class, SecurityTest.class})
+public class PasswordUtilJUnitTest {
+
+  /**
+   * Tests PasswordUtil's decrypt method (which is now deprecated) and verifies that backwards
+   * compatibility has not been broken with the removal of PasswordUtil's encryption methods.
+   * Previously encrypted passwords may still be used and decrypted.
+   */
+  @Test
+  public void testPasswordUtil() {
+    String password = "password";
+    String encrypted = "encrypted(C3CDC3485F7FF64381841CD344CBDF8A)";
+    String decrypted = PasswordUtil.decrypt(encrypted);
+    assertEquals(password, decrypted);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/43b00bd8/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java
index 800d0da..7ce0438 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java
@@ -224,7 +224,6 @@ public class TestCommand {
     createTestCommand("debug --state=on", null);
     createTestCommand("describe connection", null);
     createTestCommand("echo --string=\"Hello World!\"", null);
-    createTestCommand("encrypt password --password=value", null);
     createTestCommand("version", null);
     createTestCommand("sleep", null);
     createTestCommand("sh ls", null);
@@ -249,5 +248,5 @@ public class TestCommand {
 
     // Misc commands
     // createTestCommand("shutdown", clusterManage);
-  };
+  }
 }


[06/46] geode git commit: GEODE-2601: Fixing banner being logged twice during locator startup (now only logs once if both locator and distributed systems are started)

Posted by zh...@apache.org.
GEODE-2601: Fixing banner being logged twice during locator startup (now only logs once if both locator and distributed systems are started)


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

Branch: refs/heads/feature/GEM-1483
Commit: 31544243fd94aa8c1966e29670a4aa12363557c6
Parents: 78f08e8
Author: YehEmily <em...@gmail.com>
Authored: Thu Jun 8 14:40:39 2017 -0700
Committer: Ken Howe <kh...@pivotal.io>
Committed: Mon Jun 19 09:04:11 2017 -0700

----------------------------------------------------------------------
 .../internal/InternalDistributedSystem.java     | 32 +++++++++-----------
 .../distributed/internal/InternalLocator.java   |  3 +-
 .../internal/logging/LogWriterFactory.java      | 16 +++++-----
 3 files changed, 23 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/31544243/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
index 85f9146..d77e8b9 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
@@ -1797,7 +1797,7 @@ public class InternalDistributedSystem extends DistributedSystem
   @Override
   public Statistics[] getStatistics() {
     List<Statistics> statsList = this.statsList;
-    return (Statistics[]) statsList.toArray(new Statistics[0]);
+    return statsList.toArray(new Statistics[0]);
   }
 
   // StatisticsFactory methods
@@ -1829,7 +1829,7 @@ public class InternalDistributedSystem extends DistributedSystem
   }
 
   public FunctionStats getFunctionStats(String textId) {
-    FunctionStats stats = (FunctionStats) functionExecutionStatsMap.get(textId);
+    FunctionStats stats = functionExecutionStatsMap.get(textId);
     if (stats == null) {
       stats = new FunctionStats(this, textId);
       FunctionStats oldStats = functionExecutionStatsMap.putIfAbsent(textId, stats);
@@ -1870,7 +1870,7 @@ public class InternalDistributedSystem extends DistributedSystem
    */
   public interface StatisticsVisitor {
 
-    public void visit(Statistics stat);
+    void visit(Statistics stat);
   }
 
   public Set<String> getAllFunctionExecutionIds() {
@@ -2167,7 +2167,7 @@ public class InternalDistributedSystem extends DistributedSystem
   private void notifyResourceEventListeners(ResourceEvent event, Object resource) {
     for (Iterator<ResourceEventsListener> iter = resourceListeners.iterator(); iter.hasNext();) {
       try {
-        ResourceEventsListener listener = (ResourceEventsListener) iter.next();
+        ResourceEventsListener listener = iter.next();
         listener.handleEvent(event, resource);
       } catch (CancelException e) {
         // ignore
@@ -2302,7 +2302,7 @@ public class InternalDistributedSystem extends DistributedSystem
               boolean isDurableClient = false;
 
               if (dca != null) {
-                isDurableClient = ((dca.getId() == null || dca.getId().isEmpty()) ? false : true);
+                isDurableClient = (!(dca.getId() == null || dca.getId().isEmpty()));
               }
 
               ((InternalDistributedSystem) ds).disconnect(false,
@@ -2337,7 +2337,7 @@ public class InternalDistributedSystem extends DistributedSystem
      * 
      * @param sys the the system we are disconnecting from process should take before returning.
      */
-    public void onDisconnect(InternalDistributedSystem sys);
+    void onDisconnect(InternalDistributedSystem sys);
 
   }
 
@@ -2352,7 +2352,7 @@ public class InternalDistributedSystem extends DistributedSystem
      * @param oldSystem the old DS, which is in a partially disconnected state and cannot be used
      *        for messaging
      */
-    public void reconnecting(InternalDistributedSystem oldSystem);
+    void reconnecting(InternalDistributedSystem oldSystem);
 
     /**
      * Invoked after a reconnect to the distributed system
@@ -2360,8 +2360,7 @@ public class InternalDistributedSystem extends DistributedSystem
      * @param oldSystem the old DS
      * @param newSystem the new DS
      */
-    public void onReconnect(InternalDistributedSystem oldSystem,
-        InternalDistributedSystem newSystem);
+    void onReconnect(InternalDistributedSystem oldSystem, InternalDistributedSystem newSystem);
   }
 
   /**
@@ -2374,7 +2373,7 @@ public class InternalDistributedSystem extends DistributedSystem
      * 
      * @param sys
      */
-    public void onShutdown(InternalDistributedSystem sys);
+    void onShutdown(InternalDistributedSystem sys);
   }
 
   /**
@@ -2427,10 +2426,7 @@ public class InternalDistributedSystem extends DistributedSystem
       return false;
     }
     boolean newDsConnected = (rds == null || !rds.isConnected());
-    if (!newDsConnected) {
-      return false;
-    }
-    return true;
+    return newDsConnected;
   }
 
 
@@ -2754,7 +2750,7 @@ public class InternalDistributedSystem extends DistributedSystem
         if (newDM instanceof DistributionManager) {
           // Admin systems don't carry a cache, but for others we can now create
           // a cache
-          if (((DistributionManager) newDM).getDMType() != DistributionManager.ADMIN_ONLY_DM_TYPE) {
+          if (newDM.getDMType() != DistributionManager.ADMIN_ONLY_DM_TYPE) {
             try {
               CacheConfig config = new CacheConfig();
               if (cacheXML != null) {
@@ -2962,7 +2958,7 @@ public class InternalDistributedSystem extends DistributedSystem
     /**
      * Invoked after a connection to the distributed system is created
      */
-    public void onConnect(InternalDistributedSystem sys);
+    void onConnect(InternalDistributedSystem sys);
   }
 
   public String forceStop() {
@@ -3064,8 +3060,8 @@ public class InternalDistributedSystem extends DistributedSystem
    * Privacy Violations that Fortify will complain about.
    * </p>
    */
-  public static interface CreationStackGenerator {
+  public interface CreationStackGenerator {
 
-    public Throwable generateCreationStack(final DistributionConfig config);
+    Throwable generateCreationStack(final DistributionConfig config);
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/31544243/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
index c299dd0..ae548c4 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
@@ -478,9 +478,8 @@ public class InternalLocator extends Locator implements ConnectListener {
     if (logWriter == null) {
       logWriter = LogWriterFactory.createLogWriterLogger(false, false, this.config,
           !startDistributedSystem);
-      if (logger.isDebugEnabled()) {
+      if (logger.isDebugEnabled())
         logger.debug("LogWriter for locator is created.");
-      }
     }
 
     if (securityLogWriter == null) {

http://git-wip-us.apache.org/repos/asf/geode/blob/31544243/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterFactory.java b/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterFactory.java
index 999bca9..c4fecfd 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterFactory.java
@@ -87,19 +87,19 @@ public class LogWriterFactory {
         // LOG:CONFIG:
         logger.info(LogMarker.CONFIG, Banner.getString(null));
       }
+      System.setProperty(InternalLocator.INHIBIT_DM_BANNER, "true"); // Ensure no more banners will
+                                                                     // be logged
     } else {
       logger.debug("skipping banner - " + InternalLocator.INHIBIT_DM_BANNER + " is set to true");
     }
 
     // log the config
-    if (logConfig) {
-      if (!isLoner) {
-        // LOG:CONFIG: changed from config to info
-        logger.info(LogMarker.CONFIG,
-            LocalizedMessage.create(
-                LocalizedStrings.InternalDistributedSystem_STARTUP_CONFIGURATIONN_0,
-                config.toLoggerString()));
-      }
+    if (logConfig && !isLoner) {
+      // LOG:CONFIG: changed from config to info
+      logger.info(LogMarker.CONFIG,
+          LocalizedMessage.create(
+              LocalizedStrings.InternalDistributedSystem_STARTUP_CONFIGURATIONN_0,
+              config.toLoggerString()));
     }
 
     return logger;


[28/46] geode git commit: GEODE-2919: Provide finer grained security

Posted by zh...@apache.org.
GEODE-2919: Provide finer grained security

 - For full details, see https://cwiki.apache.org/confluence/display/GEODE/Finer+grained+security


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

Branch: refs/heads/feature/GEM-1483
Commit: 451d12e83c2457c22535ae684995e973ba8d3dd2
Parents: 3ee585c
Author: Patrick Rhomberg <pr...@pivotal.io>
Authored: Wed Jun 21 10:51:32 2017 -0700
Committer: Jared Stewart <js...@pivotal.io>
Committed: Fri Jun 23 15:46:01 2017 -0700

----------------------------------------------------------------------
 .../geode/management/CacheServerMXBean.java     | 122 ++---
 .../geode/management/DiskStoreMXBean.java       |  68 +--
 .../management/DistributedSystemMXBean.java     | 174 +++----
 .../geode/management/GatewayReceiverMXBean.java |  75 +--
 .../geode/management/GatewaySenderMXBean.java   |  88 ++--
 .../geode/management/LockServiceMXBean.java     |  20 +-
 .../apache/geode/management/MemberMXBean.java   | 263 +++++-----
 .../internal/beans/DistributedSystemMBean.java  |  21 +-
 .../management/internal/beans/MemberMBean.java  |   7 +-
 .../internal/beans/MemberMBeanBridge.java       |   4 +-
 .../internal/cli/commands/ClientCommands.java   |  90 ++--
 .../CreateAlterDestroyRegionCommands.java       |  43 +-
 .../internal/cli/commands/DataCommands.java     |  64 ++-
 .../internal/cli/commands/DeployCommands.java   |  34 +-
 .../cli/commands/DiskStoreCommands.java         | 222 ++++-----
 .../cli/commands/DurableClientCommands.java     |  90 ++--
 .../internal/cli/commands/FunctionCommands.java | 136 ++----
 .../internal/cli/commands/GfshCommand.java      |  20 +-
 .../internal/cli/commands/IndexCommands.java    | 138 +++---
 .../cli/commands/MiscellaneousCommands.java     | 258 +++++-----
 .../internal/cli/commands/PDXCommands.java      |  39 +-
 .../internal/cli/commands/QueueCommands.java    |  55 +--
 .../internal/cli/commands/RegionCommands.java   |  76 ++-
 .../internal/cli/commands/WanCommands.java      | 219 +++++----
 .../commands/lifecycle/StartPulseCommand.java   |  18 +-
 .../cli/functions/ContinuousQueryFunction.java  | 148 ++++++
 .../cli/functions/ContunuousQueryFunction.java  | 150 ------
 .../cli/functions/RegionFunctionArgs.java       |  26 +-
 .../cli/functions/UserFunctionExecution.java    |  42 +-
 .../internal/cli/i18n/CliStrings.java           |  44 +-
 .../internal/cli/remote/CommandProcessor.java   |  17 +-
 .../internal/security/MBeanServerWrapper.java   |  38 +-
 .../MemberMBeanAttributesDUnitTest.java         |  35 +-
 .../bean/stats/MemberLevelStatsJUnitTest.java   |   8 +-
 .../CreateAlterDestroyRegionCommandsTest.java   |  17 +-
 ...CacheServerMBeanAuthenticationJUnitTest.java |  20 +-
 .../CacheServerMBeanAuthorizationJUnitTest.java |  42 +-
 ...eServerMBeanWithShiroIniIntegrationTest.java |  15 +-
 .../security/CliCommandsSecurityTest.java       |  34 +-
 .../security/DataCommandsSecurityTest.java      |  13 +-
 .../security/DeployCommandsSecurityTest.java    |  28 +-
 .../DiskStoreMXBeanSecurityJUnitTest.java       |  98 ++--
 .../DistributedSystemMXBeanSecurityTest.java    |  77 +++
 .../GatewayReceiverMBeanSecurityTest.java       |  42 +-
 .../GatewaySenderMBeanSecurityTest.java         |  68 +--
 .../security/GfshCommandsPostProcessorTest.java |  28 +-
 .../security/GfshCommandsSecurityTest.java      |  76 +--
 .../LockServiceMBeanAuthorizationJUnitTest.java |  73 ++-
 .../security/MBeanSecurityJUnitTest.java        |  30 +-
 .../ManagerMBeanAuthorizationJUnitTest.java     |  30 +-
 .../security/MemberMBeanSecurityJUnitTest.java  |  51 +-
 .../internal/security/MultiUserDUnitTest.java   | 102 ++--
 .../security/ResourcePermissionTest.java        |  13 +-
 .../internal/security/TestCommand.java          | 157 +++---
 .../dunit/rules/LocatorServerStartupRule.java   |  19 +-
 .../test/dunit/rules/MemberStarterRule.java     |   6 +
 .../codeAnalysis/sanctionedSerializables.txt    |   4 +-
 .../cli/commands/ClientCommandsDUnitTest.java   | 478 ++++++++++---------
 .../internal/cli/LuceneIndexCommands.java       |  58 ++-
 .../lucene/internal/cli/LuceneIndexInfo.java    |  10 -
 .../functions/LuceneCreateIndexFunction.java    |  14 +-
 .../lucene/LuceneCommandsSecurityDUnitTest.java | 126 +++--
 .../GfshCommandsOverHttpSecurityTest.java       |   4 +-
 63 files changed, 2342 insertions(+), 2243 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/CacheServerMXBean.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/CacheServerMXBean.java b/geode-core/src/main/java/org/apache/geode/management/CacheServerMXBean.java
index 3adbf01..d0159f0 100644
--- a/geode-core/src/main/java/org/apache/geode/management/CacheServerMXBean.java
+++ b/geode-core/src/main/java/org/apache/geode/management/CacheServerMXBean.java
@@ -18,12 +18,13 @@ import org.apache.geode.cache.server.CacheServer;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
+import org.apache.geode.security.ResourcePermission.Target;
 
 /**
  * MBean that provides access to information and management functionality for a {@link CacheServer}.
  * 
  * <p>
- * The will be one CacheServermBean per {@link CacheServer} started in GemFire node.
+ * The will be one CacheServerMBean per {@link CacheServer} started in GemFire node.
  * 
  * <p>
  * ObjectName for this MBean is GemFire:service=CacheServer,port={0},type=Member,member={1}
@@ -60,48 +61,48 @@ public interface CacheServerMXBean {
   /**
    * Returns the port on which this CacheServer listens for clients.
    */
-  public int getPort();
+  int getPort();
 
   /**
    * Returns a string representing the IP address or host name that this CacheServer will listen on.
    */
-  public String getBindAddress();
+  String getBindAddress();
 
   /**
    * Returns the configured buffer size of the socket connection for this CacheServer.
    */
-  public int getSocketBufferSize();
+  int getSocketBufferSize();
 
   /**
    * Returns the maximum amount of time between client pings. This value is used to determine the
    * health of client's attached to the server.
    */
-  public int getMaximumTimeBetweenPings();
+  int getMaximumTimeBetweenPings();
 
   /**
    * Returns the maximum allowed client connections.
    */
-  public int getMaxConnections();
+  int getMaxConnections();
 
   /**
-   * Returns the maxium number of threads allowed in this CacheServer to service client requests.
+   * Returns the maximum number of threads allowed in this CacheServer to service client requests.
    */
-  public int getMaxThreads();
+  int getMaxThreads();
 
   /**
    * Returns the maximum number of messages that can be enqueued in a client-queue.
    */
-  public int getMaximumMessageCount();
+  int getMaximumMessageCount();
 
   /**
    * Returns the time (in seconds) after which a message in the client queue will expire.
    */
-  public int getMessageTimeToLive();
+  int getMessageTimeToLive();
 
   /**
    * Returns the frequency (in milliseconds) to poll the load probe on this CacheServer.
    */
-  public long getLoadPollInterval();
+  long getLoadPollInterval();
 
   /**
    * Returns the name or IP address to pass to the client as the location where the server is
@@ -111,164 +112,164 @@ public interface CacheServerMXBean {
    * and won’t be able to find the server. For this situation, you must supply the server’s
    * alternate hostname for the locator to pass to the client.
    */
-  public String getHostNameForClients();
+  String getHostNameForClients();
 
   /**
    * Returns the load probe for this CacheServer.
    */
-  public ServerLoadData fetchLoadProbe();
+  ServerLoadData fetchLoadProbe();
 
   /**
    * Returns whether or not this CacheServer is running.
    * 
    * @return True of the server is running, false otherwise.
    */
-  public boolean isRunning();
+  boolean isRunning();
 
   /**
    * Returns the capacity (in megabytes) of the client queue.
    */
-  public int getCapacity();
+  int getCapacity();
 
   /**
    * Returns the eviction policy that is executed when the capacity of the client queue is reached.
    */
-  public String getEvictionPolicy();
+  String getEvictionPolicy();
 
   /**
    * Returns the name of the disk store that is used for persistence.
    */
-  public String getDiskStoreName();
+  String getDiskStoreName();
 
   /**
    * Returns the number of sockets accepted and used for client to server messaging.
    */
-  public int getClientConnectionCount();
+  int getClientConnectionCount();
 
   /**
    * Returns the number of client virtual machines connected.
    */
-  public int getCurrentClients();
+  int getCurrentClients();
 
   /**
    * Returns the average get request latency.
    */
-  public long getGetRequestAvgLatency();
+  long getGetRequestAvgLatency();
 
   /**
    * Returns the average put request latency.
    */
-  public long getPutRequestAvgLatency();
+  long getPutRequestAvgLatency();
 
   /**
    * Returns the total number of client connections that timed out and were closed.
    */
-  public int getTotalConnectionsTimedOut();
+  int getTotalConnectionsTimedOut();
 
   /**
    * Returns the total number of client connection requests that failed.
    */
-  public int getTotalFailedConnectionAttempts();
+  int getTotalFailedConnectionAttempts();
 
   /**
    * Returns the current number of connections waiting for a thread to start processing their
    * message.
    */
-  public int getThreadQueueSize();
+  int getThreadQueueSize();
 
   /**
    * Returns the current number of threads handling a client connection.
    */
-  public int getConnectionThreads();
+  int getConnectionThreads();
 
   /**
    * Returns the load from client to server connections as reported by the load probe installed in
    * this server.
    */
-  public double getConnectionLoad();
+  double getConnectionLoad();
 
   /**
    * Returns the estimate of how much load is added for each new connection as reported by the load
    * probe installed in this server.
    */
-  public double getLoadPerConnection();
+  double getLoadPerConnection();
 
   /**
    * Returns the load from queues as reported by the load probe installed in this server.
    */
-  public double getQueueLoad();
+  double getQueueLoad();
 
   /**
    * Returns the estimate of how much load is added for each new queue as reported by the load probe
    * installed in this server.
    */
-  public double getLoadPerQueue();
+  double getLoadPerQueue();
 
 
   /**
    * Returns the rate of get requests.
    */
-  public float getGetRequestRate();
+  float getGetRequestRate();
 
   /**
    * Returns the rate of put requests.
    */
-  public float getPutRequestRate();
+  float getPutRequestRate();
 
   /**
    * Returns the total number of bytes sent to clients.
    */
-  public long getTotalSentBytes();
+  long getTotalSentBytes();
 
   /**
    * Returns the total number of bytes received from clients.
    */
-  public long getTotalReceivedBytes();
+  long getTotalReceivedBytes();
 
   /**
    * Returns the number of cache client notification requests.
    */
-  public int getNumClientNotificationRequests();
+  int getNumClientNotificationRequests();
 
   /**
    * Returns the average latency for processing client notifications.
    */
-  public long getClientNotificationAvgLatency();
+  long getClientNotificationAvgLatency();
 
   /**
    * Returns the rate of client notifications.
    */
-  public float getClientNotificationRate();
+  float getClientNotificationRate();
 
   /**
    * Returns the number of registered CQs.
    */
-  public long getRegisteredCQCount();
+  long getRegisteredCQCount();
 
   /**
    * Returns the number of active (currently executing) CQs.
    */
-  public long getActiveCQCount();
+  long getActiveCQCount();
 
   /**
    * Returns the rate of queries.
    */
-  public float getQueryRequestRate();
+  float getQueryRequestRate();
 
   /**
    * Returns the total number of indexes in use by the member.
    */
-  public int getIndexCount();
+  int getIndexCount();
 
   /**
    * Returns a list of names for all indexes.
    */
-  public String[] getIndexList();
+  String[] getIndexList();
 
   /**
    * Returns the total time spent updating indexes due to changes in the data.
    */
-  public long getTotalIndexMaintenanceTime();
+  long getTotalIndexMaintenanceTime();
 
   /**
    * Remove an index.
@@ -276,12 +277,12 @@ public interface CacheServerMXBean {
    * @param indexName Name of the index to be removed.
    */
   @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public void removeIndex(String indexName) throws Exception;
+  void removeIndex(String indexName) throws Exception;
 
   /**
    * Returns a list of names for all registered CQs.
    */
-  public String[] getContinuousQueryList();
+  String[] getContinuousQueryList();
 
   /**
    * Execute an ad-hoc CQ on the server
@@ -293,7 +294,7 @@ public interface CacheServerMXBean {
    */
   @Deprecated
   @ResourceOperation(resource = Resource.DATA, operation = Operation.READ)
-  public void executeContinuousQuery(String queryName) throws Exception;
+  void executeContinuousQuery(String queryName) throws Exception;
 
   /**
    * Stop (pause) a CQ from executing
@@ -305,8 +306,9 @@ public interface CacheServerMXBean {
    *             methods to modify a CQ.
    */
   @Deprecated
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public void stopContinuousQuery(String queryName) throws Exception;
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
+  void stopContinuousQuery(String queryName) throws Exception;
 
   /**
    * Unregister all CQs from a region
@@ -317,8 +319,9 @@ public interface CacheServerMXBean {
    *             methods to modify a CQ.
    */
   @Deprecated
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public void closeAllContinuousQuery(String regionName) throws Exception;
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
+  void closeAllContinuousQuery(String regionName) throws Exception;
 
 
   /**
@@ -330,8 +333,9 @@ public interface CacheServerMXBean {
    *             methods to modify a CQ.
    */
   @Deprecated
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public void closeContinuousQuery(String queryName) throws Exception;
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
+  void closeContinuousQuery(String queryName) throws Exception;
 
 
   /**
@@ -339,7 +343,7 @@ public interface CacheServerMXBean {
    * 
    * @return A list of IDs or a length 0 array if no clients are registered.
    */
-  public String[] getClientIds() throws Exception;
+  String[] getClientIds() throws Exception;
 
   /**
    * Returns health and statistic information for the give client id. Some of the information (CPUs,
@@ -348,44 +352,44 @@ public interface CacheServerMXBean {
    * 
    * @param clientId ID of the client for which to retrieve information.
    */
-  public ClientHealthStatus showClientStats(String clientId) throws Exception;
+  ClientHealthStatus showClientStats(String clientId) throws Exception;
 
   /**
    * Returns the number of clients who have existing subscriptions.
    */
-  public int getNumSubscriptions();
+  int getNumSubscriptions();
 
   /**
    * Returns health and statistic information for all clients. Some of the information (CPUs,
    * NumOfCacheListenerCalls, NumOfGets,NumOfMisses, NumOfPuts,NumOfThreads, ProcessCpuTime) only
    * available for clients which have set a "StatisticsInterval".
    */
-  public ClientHealthStatus[] showAllClientStats() throws Exception;
+  ClientHealthStatus[] showAllClientStats() throws Exception;
 
   /**
    * Shows a list of client with their queue statistics. Client queue statistics shown in this
    * method are the following
    * 
-   * eventsEnqued,eventsRemoved , eventsConflated ,markerEventsConflated , eventsExpired,
+   * eventsEnqueued,eventsRemoved , eventsConflated ,markerEventsConflated , eventsExpired,
    * eventsRemovedByQrm , eventsTaken , numVoidRemovals
    * 
    * @return an array of ClientQueueDetail
    * @throws Exception
    */
-  public ClientQueueDetail[] showClientQueueDetails() throws Exception;
+  ClientQueueDetail[] showClientQueueDetails() throws Exception;
 
   /**
    * 
    * Shows queue statistics of the given client. Client queue statistics shown in this method are
    * the following
    * 
-   * eventsEnqued,eventsRemoved , eventsConflated ,markerEventsConflated , eventsExpired,
+   * eventsEnqueued,eventsRemoved , eventsConflated ,markerEventsConflated , eventsExpired,
    * eventsRemovedByQrm , eventsTaken , numVoidRemovals
    * 
    * @param clientId the ID of client which is returned by the attribute ClientIds
    * @return ClientQueueDetail
    * @throws Exception
    */
-  public ClientQueueDetail showClientQueueDetails(String clientId) throws Exception;
+  ClientQueueDetail showClientQueueDetails(String clientId) throws Exception;
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/DiskStoreMXBean.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/DiskStoreMXBean.java b/geode-core/src/main/java/org/apache/geode/management/DiskStoreMXBean.java
index cca6272..6275df5 100644
--- a/geode-core/src/main/java/org/apache/geode/management/DiskStoreMXBean.java
+++ b/geode-core/src/main/java/org/apache/geode/management/DiskStoreMXBean.java
@@ -18,6 +18,7 @@ import org.apache.geode.cache.DiskStore;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
+import org.apache.geode.security.ResourcePermission.Target;
 
 /**
  * MBean that provides access to information and management functionality for a {@link DiskStore}.
@@ -31,58 +32,58 @@ public interface DiskStoreMXBean {
   /**
    * Returns the name of the DiskStore.
    */
-  public String getName();
+  String getName();
 
   /**
    * Returns whether disk files are to be automatically compacted.
    * 
    * @return True if disk files are automatically compacted, false otherwise
    */
-  public boolean isAutoCompact();
+  boolean isAutoCompact();
 
   /**
    * Returns the threshold at which an op-log may be compacted. Until it reaches this threshold the
    * op-log will not be compacted. The threshold is a percentage in the range 0..100.
    */
-  public int getCompactionThreshold();
+  int getCompactionThreshold();
 
   /**
    * Returns whether manual compaction of disk files is allowed.
    * 
    * @return True if manual compaction is allowed, false otherwise.
    */
-  public boolean isForceCompactionAllowed();
+  boolean isForceCompactionAllowed();
 
   /**
    * Returns the maximum size (in megabytes) that a single op-log can grow to.
    */
-  public long getMaxOpLogSize();
+  long getMaxOpLogSize();
 
   /**
    * Returns the time (in milliseconds) that can elapse before unwritten data is saved to disk.
    */
-  public long getTimeInterval();
+  long getTimeInterval();
 
   /**
    * Returns the size of the write buffer that this DiskStore will use when writing data to disk.
    */
-  public int getWriteBufferSize();
+  int getWriteBufferSize();
 
   /**
    * Returns the path of the directories to which the region's data will be written.
    */
-  public String[] getDiskDirectories();
+  String[] getDiskDirectories();
 
   /**
    * Returns the maximum number of operations that can be asynchronously queued for saving to disk.
    * When this limit is reached operations will block until they can be put in the queue.
    */
-  public int getQueueSize();
+  int getQueueSize();
 
   /**
    * Returns the total number of bytes of space this DiskStore has used.
    */
-  public long getTotalBytesOnDisk();
+  long getTotalBytesOnDisk();
 
   /**
    * Returns the average latency of disk reads in nanoseconds Its the average latency required to
@@ -92,7 +93,7 @@ public interface DiskStoreMXBean {
    * So this rate won't match the number of bytes put in all regions.This is rate of actual bytes
    * system is persisting.
    */
-  public float getDiskReadsRate();
+  float getDiskReadsRate();
 
   /**
    * Returns the average latency of disk writes in nanoseconds. Its the average latency required to
@@ -102,44 +103,44 @@ public interface DiskStoreMXBean {
    * So this rate won't match the number of bytes put in all regions. This is rate of actual bytes
    * system is persisting.
    */
-  public float getDiskWritesRate();
+  float getDiskWritesRate();
 
   /**
    * Returns the disk reads average latency in nanoseconds. It depicts average time needed to read
    * one byte of data from disk.
    */
-  public long getDiskReadsAvgLatency();
+  long getDiskReadsAvgLatency();
 
   /**
    * Returns the disk writes average latency in nanoseconds. It depicts average time needed to write
    * one byte of data to disk.
    */
-  public long getDiskWritesAvgLatency();
+  long getDiskWritesAvgLatency();
 
   /**
    * Returns the flush time average latency.
    */
-  public long getFlushTimeAvgLatency();
+  long getFlushTimeAvgLatency();
 
   /**
    * Returns the number of entries in the asynchronous queue waiting to be written to disk.
    */
-  public int getTotalQueueSize();
+  int getTotalQueueSize();
 
   /**
    * Returns the number of backups currently in progress on this DiskStore.
    */
-  public int getTotalBackupInProgress();
+  int getTotalBackupInProgress();
 
   /**
    * Returns the number of backups of this DiskStore that have been completed.
    */
-  public int getTotalBackupCompleted();
+  int getTotalBackupCompleted();
 
   /**
    * Returns the number of persistent regions currently being recovered from disk.
    */
-  public int getTotalRecoveriesInProgress();
+  int getTotalRecoveriesInProgress();
 
   /**
    * Requests the DiskStore to start writing to a new op-log. The old oplog will be asynchronously
@@ -149,8 +150,9 @@ public interface DiskStoreMXBean {
    * compaction is true then the application will wait for the other op-logs to be compacted and
    * additional space is available.
    */
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public void forceRoll();
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.DISK)
+  void forceRoll();
 
   /**
    * Requests the DiskStore to start compacting. The compaction is done even if automatic compaction
@@ -161,15 +163,17 @@ public interface DiskStoreMXBean {
    * @return True if one or more op-logs were compacted or false to indicate that no op-logs were
    *         ready to be compacted or that a compaction was already in progress.
    */
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public boolean forceCompaction();
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.DISK)
+  boolean forceCompaction();
 
   /**
    * Causes any data that is currently in the asynchronous queue to be written to disk. Does not
    * return until the flush is complete.
    */
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public void flush();
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.DISK)
+  void flush();
 
   /**
    * Returns the warning threshold for disk usage as a percentage of the total disk volume.
@@ -177,7 +181,7 @@ public interface DiskStoreMXBean {
    * @return the warning percent
    * @since GemFire 8.0
    */
-  public float getDiskUsageWarningPercentage();
+  float getDiskUsageWarningPercentage();
 
   /**
    * Returns the critical threshold for disk usage as a percentage of the total disk volume.
@@ -185,21 +189,23 @@ public interface DiskStoreMXBean {
    * @return the critical percent
    * @since GemFire 8.0
    */
-  public float getDiskUsageCriticalPercentage();
+  float getDiskUsageCriticalPercentage();
 
   /**
    * Sets the value of the disk usage warning percentage.
    * 
    * @param warningPercent the warning percent
    */
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public void setDiskUsageWarningPercentage(float warningPercent);
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.DISK)
+  void setDiskUsageWarningPercentage(float warningPercent);
 
   /**
    * Sets the value of the disk usage critical percentage.
    * 
    * @param criticalPercent the critical percent
    */
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public void setDiskUsageCriticalPercentage(float criticalPercent);
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.DISK)
+  void setDiskUsageCriticalPercentage(float criticalPercent);
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/DistributedSystemMXBean.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/DistributedSystemMXBean.java b/geode-core/src/main/java/org/apache/geode/management/DistributedSystemMXBean.java
index f6f701e..3d52115 100644
--- a/geode-core/src/main/java/org/apache/geode/management/DistributedSystemMXBean.java
+++ b/geode-core/src/main/java/org/apache/geode/management/DistributedSystemMXBean.java
@@ -15,6 +15,7 @@
 package org.apache.geode.management;
 
 import java.util.Map;
+
 import javax.management.ObjectName;
 
 import org.apache.geode.cache.DiskStore;
@@ -24,6 +25,7 @@ import org.apache.geode.distributed.DistributedSystem;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
+import org.apache.geode.security.ResourcePermission.Target;
 
 /**
  * MBean that provides access to information and management operations for a
@@ -76,22 +78,22 @@ import org.apache.geode.security.ResourcePermission.Resource;
 public interface DistributedSystemMXBean {
 
   /**
-   * Returns the ID of thie DistributedSystem. allow anyone to access this method
+   * Returns the ID of the DistributedSystem. allow anyone to access this method
    *
    * @return The DistributedSystem ID or -1 if not set.
    */
   @ResourceOperation()
-  public int getDistributedSystemId();
+  int getDistributedSystemId();
 
   /**
    * Returns the number of members in the distributed system.
    */
-  public int getMemberCount();
+  int getMemberCount();
 
   /**
    * Returns a list of names for all members.
    */
-  public String[] listMembers();
+  String[] listMembers();
 
   /**
    * Returns a list of names for locator members.
@@ -101,49 +103,49 @@ public interface DistributedSystemMXBean {
    * @return a list of names for locator members.
    */
 
-  public String[] listLocatorMembers(boolean onlyStandAloneLocators);
+  String[] listLocatorMembers(boolean onlyStandAloneLocators);
 
   /**
    * Returns a list of names for all groups.
    */
-  public String[] listGroups();
+  String[] listGroups();
 
   /**
    * Returns the number of locators in the distributed system.
    */
-  public int getLocatorCount();
+  int getLocatorCount();
 
   /**
    * Returns a list of IDs for all locators.
    */
-  public String[] listLocators(); // TODO - Abhishek Should be renamed to
-                                  // listLocatorDiscoveryConfigurations? Do we need something for
-                                  // mcast too?
+  String[] listLocators(); // TODO - Abhishek Should be renamed to
+                           // listLocatorDiscoveryConfigurations? Do we need something for
+                           // mcast too?
 
   /**
    * Returns the number of disks stores in the distributed system.
    */
-  public int getSystemDiskStoreCount();
+  int getSystemDiskStoreCount();
 
   /**
    * Returns a map of all {@link DistributedMember}s and their {@link DiskStore}s.
    */
-  public Map<String, String[]> listMemberDiskstore();
+  Map<String, String[]> listMemberDiskstore();
 
   /**
    * Returns a list of IDs for all gateway senders.
    */
-  public String[] listGatewaySenders();
+  String[] listGatewaySenders();
 
   /**
    * Returns a list of IDs for all gateway receivers.
    */
-  public String[] listGatewayReceivers();
+  String[] listGatewayReceivers();
 
   /**
    * Returns the minimum level set for alerts to be delivered to listeners.
    */
-  public String getAlertLevel();
+  String getAlertLevel();
 
   /**
    * Sets the minimum level for alerts to be delivered to listeners.
@@ -152,74 +154,74 @@ public interface DistributedSystemMXBean {
    *        SEVERE or NONE.
    */
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.WRITE)
-  public void changeAlertLevel(String alertLevel) throws Exception;
+  void changeAlertLevel(String alertLevel) throws Exception;
 
   /**
    * Returns the total available heap (in megabytes) across all distributed members.
    */
-  public long getTotalHeapSize();
+  long getTotalHeapSize();
 
   /**
    * Returns the total number of entries in all regions.
    */
-  public long getTotalRegionEntryCount();
+  long getTotalRegionEntryCount();
 
   /**
    * Returns the number of {@link Region}s.
    */
 
-  public int getTotalRegionCount();
+  int getTotalRegionCount();
 
   /**
    * Returns the number of times that a cache miss occurred for all regions.
    */
-  public int getTotalMissCount();
+  int getTotalMissCount();
 
   /**
    * Returns the number of times that a hit occurred for all regions.
    */
-  public int getTotalHitCount();
+  int getTotalHitCount();
 
   /**
    * Returns the number of connected clients.
    */
-  public int getNumClients();
+  int getNumClients();
 
 
   /**
    * Returns the average number of disk reads per second across all distributed members.
    */
-  public float getDiskReadsRate();
+  float getDiskReadsRate();
 
   /**
    * Returns the average number of disk writes per second across all distributed members.
    */
-  public float getDiskWritesRate();
+  float getDiskWritesRate();
 
   /**
    * Returns the average disk flush latency time.
    */
-  public long getDiskFlushAvgLatency();
+  long getDiskFlushAvgLatency();
 
   /**
    * Returns the number of backups currently in progress for all disk stores.
    */
-  public int getTotalBackupInProgress();
+  int getTotalBackupInProgress();
 
   /**
    * Returns the number of initial images in progress.
    */
-  public int getNumInitialImagesInProgress();
+  int getNumInitialImagesInProgress();
 
   /**
    * Returns the number of active (currently executing) CQs for all cache servers.
    */
-  public long getActiveCQCount();
+  long getActiveCQCount();
 
   /**
    * Returns the average number of queries per second across all distributed members.
    */
-  public float getQueryRequestRate();
+  float getQueryRequestRate();
 
   /**
    * Performs a backup on all members.
@@ -229,8 +231,7 @@ public interface DistributedSystemMXBean {
    * @return The results of the backup request.
    */
   @ResourceOperation(resource = Resource.DATA, operation = Operation.READ)
-  public DiskBackupStatus backupAllMembers(String targetDirPath, String baselineDirPath)
-      throws Exception;
+  DiskBackupStatus backupAllMembers(String targetDirPath, String baselineDirPath) throws Exception;
 
   /**
    * Returns the configuration information for a distributed member.
@@ -239,7 +240,7 @@ public interface DistributedSystemMXBean {
    * @return The configuration information for a member.
    * @throws Exception for an invalid member ID.
    */
-  public GemFireProperties fetchMemberConfiguration(String member) throws Exception;
+  GemFireProperties fetchMemberConfiguration(String member) throws Exception;
 
   /**
    * Returns the total time (in seconds) since a distributed member was started.
@@ -248,21 +249,21 @@ public interface DistributedSystemMXBean {
    * @return The total time (in seconds) since a member was started.
    * @throws Exception for an invalid member ID.
    */
-  public long fetchMemberUpTime(String member) throws Exception;
+  long fetchMemberUpTime(String member) throws Exception;
 
   /**
    * Returns a list of names for all cache servers which are able to serve requests from GemFire
    * clients.
    * 
    */
-  public String[] listCacheServers();
+  String[] listCacheServers();
 
 
   /**
    * Returns a list of names for all servers where server means any long-running GemFire process
    * that was started with "start server" command from GFSH.
    */
-  public String[] listServers();
+  String[] listServers();
 
   /**
    * Returns JVM metrics for a distributed member.
@@ -270,7 +271,7 @@ public interface DistributedSystemMXBean {
    * @param member Name or ID of the member.
    * @throws Exception for an invalid member ID.
    */
-  public JVMMetrics showJVMMetrics(String member) throws Exception;
+  JVMMetrics showJVMMetrics(String member) throws Exception;
 
   /**
    * Returns operating system metrics for a distributed member.
@@ -278,7 +279,7 @@ public interface DistributedSystemMXBean {
    * @param member Name or ID of the member.
    * @throws Exception for an invalid member ID.
    */
-  public OSMetrics showOSMetrics(String member) throws Exception;
+  OSMetrics showOSMetrics(String member) throws Exception;
 
   /**
    * Returns network metrics for a distributed member.
@@ -286,7 +287,7 @@ public interface DistributedSystemMXBean {
    * @param member Name or ID of the member.
    * @throws Exception for an invalid member ID.
    */
-  public NetworkMetrics showNetworkMetric(String member) throws Exception;
+  NetworkMetrics showNetworkMetric(String member) throws Exception;
 
   /**
    * Returns disk metrics for a distributed member.
@@ -294,7 +295,7 @@ public interface DistributedSystemMXBean {
    * @param member Name or ID of the member.
    * @throws Exception for an invalid member ID.
    */
-  public DiskMetrics showDiskMetrics(String member) throws Exception;
+  DiskMetrics showDiskMetrics(String member) throws Exception;
 
   /**
    * Shuts down all members of a distributed system except for the managing member.
@@ -302,17 +303,17 @@ public interface DistributedSystemMXBean {
    * @return List of names of all distributed members that were shutdown.
    */
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE)
-  public String[] shutDownAllMembers() throws Exception;
+  String[] shutDownAllMembers() throws Exception;
 
   /**
    * Returns a list of names for all regions.
    */
-  public String[] listRegions();
+  String[] listRegions();
 
   /**
    * Returns a list of full paths for all regions.
    */
-  public String[] listAllRegionPaths();
+  String[] listAllRegionPaths();
 
   /**
    * Removes a disk store from the distributed system.
@@ -320,40 +321,41 @@ public interface DistributedSystemMXBean {
    * @param diskStoreId UUID of the disk store to remove
    * @return True if the request is successful, false otherwise.
    */
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public boolean revokeMissingDiskStores(String diskStoreId) throws Exception;
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.DISK)
+  boolean revokeMissingDiskStores(String diskStoreId);
 
   /**
    * Returns a list of details for disk stores which have been determined to be unavailable during
    * the recovery of region.
    */
-  public PersistentMemberDetails[] listMissingDiskStores();
+  PersistentMemberDetails[] listMissingDiskStores();
 
   /**
    * Returns the object name for a {@link MemberMXBean} used to access this distributed member.
    * allow anyone to access this method
    */
   @ResourceOperation()
-  public ObjectName getMemberObjectName();
+  ObjectName getMemberObjectName();
 
   /**
    * Returns the object name for a {@link ManagerMXBean} used to access the management service
    * running on this distributed member.
    */
-  public ObjectName getManagerObjectName();
+  ObjectName getManagerObjectName();
 
   /**
    * Returns a list of object names for the {@link MemberMXBean}s used to access all distributed
    * members.
    */
-  public ObjectName[] listMemberObjectNames();
+  ObjectName[] listMemberObjectNames();
 
   /**
    * Returns the object name for a {@link MemberMXBean} used to access a distributed member..
    *
    * @param member Name or ID of the member.
    */
-  public ObjectName fetchMemberObjectName(String member) throws Exception;
+  ObjectName fetchMemberObjectName(String member) throws Exception;
 
   /**
    * Returns a list of object names for the {@link RegionMXBean}s used to access all regions on a
@@ -361,7 +363,7 @@ public interface DistributedSystemMXBean {
    *
    * @param memberMBeanName ObjectName of the member.
    */
-  public ObjectName[] fetchRegionObjectNames(ObjectName memberMBeanName) throws Exception;
+  ObjectName[] fetchRegionObjectNames(ObjectName memberMBeanName) throws Exception;
 
   /**
    * Returns a list of object names for the {@link DistributedRegionMXBean}s used to access all
@@ -369,7 +371,7 @@ public interface DistributedSystemMXBean {
    *
    * @return An array of object names or an empty array if no distributed regions are found.
    */
-  public ObjectName[] listDistributedRegionObjectNames();
+  ObjectName[] listDistributedRegionObjectNames();
 
   /**
    * Returns the object name for a {@link DistributedRegionMXBean} used to access a distributed
@@ -377,7 +379,7 @@ public interface DistributedSystemMXBean {
    *
    * @param regionPath Full path of the region.
    */
-  public ObjectName fetchDistributedRegionObjectName(String regionPath) throws Exception;
+  ObjectName fetchDistributedRegionObjectName(String regionPath) throws Exception;
 
   /**
    * Returns the object name for a {@link RegionMXBean} used to access a region.
@@ -385,7 +387,7 @@ public interface DistributedSystemMXBean {
    * @param member Name or ID of the member.
    * @param regionPath Full path of the region.
    */
-  public ObjectName fetchRegionObjectName(String member, String regionPath) throws Exception;
+  ObjectName fetchRegionObjectName(String member, String regionPath) throws Exception;
 
   /**
    * Returns the object name for a {@link GatewaySenderMXBean} used to access a gateway sender.
@@ -393,14 +395,14 @@ public interface DistributedSystemMXBean {
    * @param member Name or ID of the member.
    * @param senderId ID of a gateway sender.
    */
-  public ObjectName fetchGatewaySenderObjectName(String member, String senderId) throws Exception;
+  ObjectName fetchGatewaySenderObjectName(String member, String senderId) throws Exception;
 
   /**
    * Returns the object name for a {@link GatewayReceiverMXBean} used to access a gateway receiver.
    *
    * @param member Name or ID of the member.
    */
-  public ObjectName fetchGatewayReceiverObjectName(String member) throws Exception;
+  ObjectName fetchGatewayReceiverObjectName(String member) throws Exception;
 
   /**
    * Returns a list of object names for the {@link GatewaySenderMXBean}s used to access all gateway
@@ -408,7 +410,7 @@ public interface DistributedSystemMXBean {
    *
    * @return An array of object names or an empty array if no gateway senders are found.
    */
-  public ObjectName[] listGatewaySenderObjectNames();
+  ObjectName[] listGatewaySenderObjectNames();
 
   /**
    * Returns a list of object names for the {@link GatewaySenderMXBean}s used to access all gateway
@@ -416,7 +418,7 @@ public interface DistributedSystemMXBean {
    *
    * @param member Name or ID of the member.
    */
-  public ObjectName[] listGatewaySenderObjectNames(String member) throws Exception;
+  ObjectName[] listGatewaySenderObjectNames(String member) throws Exception;
 
   /**
    * Returns a list of object names for the {@link GatewayReceiverMXBean}s used to access all
@@ -424,7 +426,7 @@ public interface DistributedSystemMXBean {
    *
    * @return An array of object names or an empty array if no gateway receivers are found.
    */
-  public ObjectName[] listGatewayReceiverObjectNames();
+  ObjectName[] listGatewayReceiverObjectNames();
 
   /**
    * Returns the object name for a {@link DistributedLockServiceMXBean} used to access a distributed
@@ -432,7 +434,7 @@ public interface DistributedSystemMXBean {
    *
    * @param lockServiceName Name of the lock service.
    */
-  public ObjectName fetchDistributedLockServiceObjectName(String lockServiceName) throws Exception;
+  ObjectName fetchDistributedLockServiceObjectName(String lockServiceName) throws Exception;
 
   /**
    * Returns the object name for a {@link LockServiceMXBean} used to access a lock service.
@@ -440,7 +442,7 @@ public interface DistributedSystemMXBean {
    * @param member Name or Id of the member.
    * @param lockService Name of the lock service.
    */
-  public ObjectName fetchLockServiceObjectName(String member, String lockService) throws Exception;
+  ObjectName fetchLockServiceObjectName(String member, String lockService) throws Exception;
 
   /**
    * Returns object name of a {@link DiskStoreMXBean} for a given name and member
@@ -450,7 +452,7 @@ public interface DistributedSystemMXBean {
    * @return a ObjectName
    * @throws Exception
    */
-  public ObjectName fetchDiskStoreObjectName(String member, String diskStoreName) throws Exception;
+  ObjectName fetchDiskStoreObjectName(String member, String diskStoreName) throws Exception;
 
   /**
    * Returns the object name for a {@link CacheServerMXBean} used to access a cache server.
@@ -458,70 +460,70 @@ public interface DistributedSystemMXBean {
    * @param member Name or ID of the member.
    * @param port Port of the server.
    */
-  public ObjectName fetchCacheServerObjectName(String member, int port) throws Exception;
+  ObjectName fetchCacheServerObjectName(String member, int port) throws Exception;
 
   /**
    * Returns a list of object names for the {@link CacheServerMXBean}s used to access all cache
    * servers.
    */
-  public ObjectName[] listCacheServerObjectNames();
+  ObjectName[] listCacheServerObjectNames();
 
   /**
    * Returns the number of map-reduce jobs currently running on all members in the distributed
    * system.
    */
-  public int getNumRunningFunctions();
+  int getNumRunningFunctions();
 
   /**
    * Returns the number of CQs registers on all members.
    */
-  public long getRegisteredCQCount();
+  long getRegisteredCQCount();
 
   /**
    * Returns the number of bytes used on all disks.
    */
-  public long getTotalDiskUsage();
+  long getTotalDiskUsage();
 
   /**
    * Returns the total heap used on all members.
    */
-  public long getUsedHeapSize();
+  long getUsedHeapSize();
 
   /**
    * Returns the average number of reads per second for all members.
    */
-  public float getAverageReads();
+  float getAverageReads();
 
   /**
    * Returns the average writes per second, including both put and putAll operations, for all
    * members.
    */
-  public float getAverageWrites();
+  float getAverageWrites();
 
   /**
    * Returns the number of subscriptions for all members.
    */
-  public int getNumSubscriptions();
+  int getNumSubscriptions();
 
 
   /**
    * Returns the number of garbage collection operations for all members.
    */
-  public long getGarbageCollectionCount();
+  long getGarbageCollectionCount();
 
   /**
    * Returns a map of remote distributed system IDs and the current connection status for each.
    */
-  public Map<String, Boolean> viewRemoteClusterStatus();
+  Map<String, Boolean> viewRemoteClusterStatus();
 
   /**
    * Returns the number JVM pauses (which may or may not include full garbage collection pauses)
    * detected by GemFire.
    */
-  public long getJVMPauses();
+  long getJVMPauses();
 
   /**
-   * This API is used to query data from GemFire system. This returns a JSON formated String having
+   * This API is used to query data from GemFire system. This returns a JSON formatted String having
    * data and it's type. Type and value of data makes an array , type preceding the value.
    * 
    * e.g. {"result":[["java.lang.String","v"],["java.lang.String","b"]]}
@@ -548,10 +550,10 @@ public interface DistributedSystemMXBean {
    *        mandatory to give this input barring join queries on PR. If member list is not provided
    *        query will be for the whole cluster.
    * @param limit result set limit. If not set or 0 is passed default limit of 1000 will be set.
-   * @return a JSON formated string containing data and its type
+   * @return a JSON formatted string containing data and its type
    */
   @ResourceOperation(resource = Resource.DATA, operation = Operation.READ)
-  public String queryData(String queryString, String members, int limit) throws Exception;
+  String queryData(String queryString, String members, int limit) throws Exception;
 
   /**
    * 
@@ -575,7 +577,7 @@ public interface DistributedSystemMXBean {
    * @return a byte[] which is a compressed JSON string.
    */
   @ResourceOperation(resource = Resource.DATA, operation = Operation.READ)
-  public byte[] queryDataForCompressedResult(String queryString, String members, int limit)
+  byte[] queryDataForCompressedResult(String queryString, String members, int limit)
       throws Exception;
 
 
@@ -583,31 +585,33 @@ public interface DistributedSystemMXBean {
    * Returns the number of committed transactions across all members. It gives point in time value
    * i.e. Number of tx committed at the time of reading this value
    */
-  public int getTransactionCommitted();
+  int getTransactionCommitted();
 
   /**
    * Returns the number of transactions that were rolled back across all members. It gives point in
    * time value i.e. Number of tx rolled back at the time of reading this value
    */
-  public int getTransactionRolledBack();
+  int getTransactionRolledBack();
 
   /**
    * Number of rows DistributedSystemMXBean.queryData() operation will return. By default it will be
    * 1000. User can modify this to control number of rows to be shown on Pulse, as Pulse DataBrowser
    * internally uses DistributedSystemMXBean.queryData()
    */
-  public int getQueryResultSetLimit();
+  int getQueryResultSetLimit();
 
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public void setQueryResultSetLimit(int queryResultSetLimit);
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
+  void setQueryResultSetLimit(int queryResultSetLimit);
 
   /**
    * Number of elements in a collection to be shown in queryData operation if query results contain
    * collections like Map, List etc.
    * 
    */
-  public int getQueryCollectionsDepth();
+  int getQueryCollectionsDepth();
 
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public void setQueryCollectionsDepth(int queryCollectionsDepth);
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
+  void setQueryCollectionsDepth(int queryCollectionsDepth);
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/GatewayReceiverMXBean.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/GatewayReceiverMXBean.java b/geode-core/src/main/java/org/apache/geode/management/GatewayReceiverMXBean.java
index 749a743..556bd6f 100644
--- a/geode-core/src/main/java/org/apache/geode/management/GatewayReceiverMXBean.java
+++ b/geode-core/src/main/java/org/apache/geode/management/GatewayReceiverMXBean.java
@@ -18,6 +18,7 @@ import org.apache.geode.cache.wan.GatewayReceiver;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
+import org.apache.geode.security.ResourcePermission.Target;
 
 /**
  * MBean that provides access to information and management functionality for a
@@ -32,180 +33,182 @@ public interface GatewayReceiverMXBean {
   /**
    * Returns the port the receiver is listening on.
    */
-  public int getPort();
+  int getPort();
 
   /**
    * Returns the configured buffer size of the socket connection.
    */
-  public int getSocketBufferSize();
+  int getSocketBufferSize();
 
   /**
    * Returns the bind address on the host.
    */
-  public String getBindAddress();
+  String getBindAddress();
 
   /**
    * Returns the maximum amount of time between client pings.
    */
-  public int getMaximumTimeBetweenPings();
+  int getMaximumTimeBetweenPings();
 
   /**
    * Returns whether the receiver is in running state.
    * 
    * @return True if the receiver is in a running state, false otherwise.
    */
-  public boolean isRunning();
+  boolean isRunning();
 
   /**
    * Returns the instantaneous rate of events received.
    */
-  public float getEventsReceivedRate();
+  float getEventsReceivedRate();
 
   /**
    * Returns the rate of create requests received.
    */
-  public float getCreateRequestsRate();
+  float getCreateRequestsRate();
 
   /**
    * Returns the rate of update requests received.
    */
-  public float getUpdateRequestsRate();
+  float getUpdateRequestsRate();
 
   /**
    * Returns the rate of destroy requests received.
    */
-  public float getDestroyRequestsRate();
+  float getDestroyRequestsRate();
 
   /**
    * Returns the number of duplicate batches which have been received.
    */
-  public int getDuplicateBatchesReceived();
+  int getDuplicateBatchesReceived();
 
   /**
    * Returns the number of batches which have been received out of order.
    */
-  public int getOutoforderBatchesReceived();
+  int getOutoforderBatchesReceived();
 
   /**
    * Starts the gateway receiver.
    */
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public void start() throws Exception;
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.GATEWAY)
+  void start() throws Exception;
 
   /**
    * Stops the gateway receiver.
    */
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public void stop() throws Exception;
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.GATEWAY)
+  void stop() throws Exception;
 
   /**
    * Returns the configured start port.
    */
-  public int getStartPort();
+  int getStartPort();
 
   /**
    * Returns the configured end port.
    */
-  public int getEndPort();
+  int getEndPort();
 
   /**
    * Returns a list of names for the transport filters in use.
    */
-  public String[] getGatewayTransportFilters();
+  String[] getGatewayTransportFilters();
 
   /**
    * Returns the number of sockets accepted and used for client to server messaging.
    */
-  public int getClientConnectionCount();
+  int getClientConnectionCount();
 
   /**
    * Returns the number of client virtual machines connected and acting as a gateway.
    */
-  public int getNumGateways();
+  int getNumGateways();
 
   /**
    * Returns the average get request latency.
    */
-  public long getGetRequestAvgLatency();
+  long getGetRequestAvgLatency();
 
   /**
    * Returns the average put request latency.
    */
-  public long getPutRequestAvgLatency();
+  long getPutRequestAvgLatency();
 
   /**
    * Returns the total number of client connections that timed out and were closed.
    */
-  public int getTotalConnectionsTimedOut();
+  int getTotalConnectionsTimedOut();
 
   /**
    * Returns the total number of client connection requests that failed.
    */
-  public int getTotalFailedConnectionAttempts();
+  int getTotalFailedConnectionAttempts();
 
   /**
    * Returns the current number of connections waiting for a thread to start processing their
    * message.
    */
-  public int getThreadQueueSize();
+  int getThreadQueueSize();
 
   /**
    * Returns the current number of threads handling a client connection.
    */
-  public int getConnectionThreads();
+  int getConnectionThreads();
 
   /**
    * Returns the load from client to server connections as reported by the load probe installed in
    * this server.
    */
-  public double getConnectionLoad();
+  double getConnectionLoad();
 
   /**
    * Returns the estimate of how much load is added for each new connection as reported by the load
    * probe installed in this server.
    */
-  public double getLoadPerConnection();
+  double getLoadPerConnection();
 
   /**
    * Returns the load from queues as reported by the load probe installed in this server.
    */
-  public double getQueueLoad();
+  double getQueueLoad();
 
   /**
    * Returns the estimate of how much load is added for each new queue as reported by the load probe
    * installed in this server.
    */
-  public double getLoadPerQueue();
+  double getLoadPerQueue();
 
   /**
    * Returns the rate of get requests.
    */
-  public float getGetRequestRate();
+  float getGetRequestRate();
 
   /**
    * Returns the rate of put requests.
    */
-  public float getPutRequestRate();
+  float getPutRequestRate();
 
   /**
    * Returns the total number of bytes sent to clients.
    */
-  public long getTotalSentBytes();
+  long getTotalSentBytes();
 
   /**
    * Returns the total number of bytes received from clients.
    */
-  public long getTotalReceivedBytes();
+  long getTotalReceivedBytes();
 
   /**
    * Returns a list of the host and port information for gateway senders connected to this gateway
    * receiver.
    */
-  public String[] getConnectedGatewaySenders();
+  String[] getConnectedGatewaySenders();
 
   /**
    * Returns the average batch processing time (in milliseconds).
    */
-  public long getAverageBatchProcessingTime();
+  long getAverageBatchProcessingTime();
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/GatewaySenderMXBean.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/GatewaySenderMXBean.java b/geode-core/src/main/java/org/apache/geode/management/GatewaySenderMXBean.java
index 718a9be..f8cad87 100644
--- a/geode-core/src/main/java/org/apache/geode/management/GatewaySenderMXBean.java
+++ b/geode-core/src/main/java/org/apache/geode/management/GatewaySenderMXBean.java
@@ -18,6 +18,7 @@ import org.apache.geode.cache.wan.GatewaySender;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
+import org.apache.geode.security.ResourcePermission.Target;
 
 /**
  * MBean that provides access to information and management functionality for a
@@ -32,51 +33,51 @@ public interface GatewaySenderMXBean {
   /**
    * Returns the ID of the GatewaySender.
    */
-  public String getSenderId();
+  String getSenderId();
 
   /**
    * Returns the id of the remote <code>GatewayReceiver</code>'s DistributedSystem.
    */
-  public int getRemoteDSId();
+  int getRemoteDSId();
 
   /**
    * Returns the configured buffer size of the socket connection between this GatewaySender and its
    * receiving <code>GatewayReceiver</code>.
    */
-  public int getSocketBufferSize();
+  int getSocketBufferSize();
 
   /**
    * Returns the amount of time (in milliseconds) that a socket read between a sending GatewaySender
    * and its receiving <code>GatewayReceiver</code> is allowed to block.
    */
-  public long getSocketReadTimeout();
+  long getSocketReadTimeout();
 
   /**
    * Returns the name of the disk store that is used for persistence.
    */
-  public String getOverflowDiskStoreName();
+  String getOverflowDiskStoreName();
 
   /**
    * Returns the maximum memory after which the data needs to be overflowed to disk.
    */
-  public int getMaximumQueueMemory();
+  int getMaximumQueueMemory();
 
   /**
    * Returns the size of a batch that gets delivered by the GatewaySender.
    */
-  public int getBatchSize();
+  int getBatchSize();
 
   /**
    * Returns the interval between transmissions by the GatewaySender.
    */
-  public long getBatchTimeInterval();
+  long getBatchTimeInterval();
 
   /**
    * Returns whether batch conflation for the GatewaySender's queue is enabled
    * 
    * @return True if batch conflation is enabled, false otherwise.
    */
-  public boolean isBatchConflationEnabled();
+  boolean isBatchConflationEnabled();
 
   /**
    * Returns whether the GatewaySender is configured to be persistent or non-persistent.
@@ -84,162 +85,167 @@ public interface GatewaySenderMXBean {
    * @return True if the sender is persistent, false otherwise.
    */
 
-  public boolean isPersistenceEnabled();
+  boolean isPersistenceEnabled();
 
   /**
    * Returns the alert threshold for entries in a GatewaySender's queue.The default value is 0
    * milliseconds in which case no alert will be logged if events are delayed in Queue.
    */
-  public int getAlertThreshold();
+  int getAlertThreshold();
 
   /**
    * Returns a list of <code>GatewayEventFilter</code>s added to this GatewaySender.
    */
-  public String[] getGatewayEventFilters();
+  String[] getGatewayEventFilters();
 
   /**
    * Returns a list of <code>GatewayTransportFilter</code>s added to this GatewaySender.
    */
-  public String[] getGatewayTransportFilters();
+  String[] getGatewayTransportFilters();
 
   /**
    * Returns whether the GatewaySender is configured for manual start.
    * 
    * @return True if the GatewaySender is configured for manual start, false otherwise.
    */
-  public boolean isManualStart();
+  boolean isManualStart();
 
   /**
    * Returns whether or not this GatewaySender is running.
    * 
    * @return True if the GatewaySender is running, false otherwise.
    */
-  public boolean isRunning();
+  boolean isRunning();
 
   /**
    * Returns whether or not this GatewaySender is paused.
    * 
    * @return True of the GatewaySender is paused, false otherwise.
    */
-  public boolean isPaused();
+  boolean isPaused();
 
   /**
    * Returns the rate of events received per second by this Sender if it's a serial-wan.
    */
-  public float getEventsReceivedRate();
+  float getEventsReceivedRate();
 
   /**
    * Returns the rate of events being queued.
    */
-  public float getEventsQueuedRate();
+  float getEventsQueuedRate();
 
   /**
    * Returns the current size of the event queue.
    */
-  public int getEventQueueSize();
+  int getEventQueueSize();
 
   /**
    * Returns the number of events received, but not added to the event queue, because the queue
    * already contains an event with the same key.
    */
-  public int getTotalEventsConflated();
+  int getTotalEventsConflated();
 
 
   /**
    * Returns the average number of batches sent per second.
    */
-  public float getBatchesDispatchedRate();
+  float getBatchesDispatchedRate();
 
   /**
    * Returns the average time taken to send a batch of events.
    */
-  public long getAverageDistributionTimePerBatch();
+  long getAverageDistributionTimePerBatch();
 
   /**
    * Returns the total number of batches of events that were resent.
    */
-  public int getTotalBatchesRedistributed();
+  int getTotalBatchesRedistributed();
 
   /**
    * Starts this GatewaySender. Once the GatewaySender is running its configuration cannot be
    * changed.
    * 
    */
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public void start();
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.GATEWAY)
+  void start();
 
   /**
    * Stops this GatewaySender.
    */
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public void stop();
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.GATEWAY)
+  void stop();
 
   /**
    * Pauses this GatewaySender.
    */
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public void pause();
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.GATEWAY)
+  void pause();
 
   /**
    * Resumes this paused GatewaySender.
    */
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public void resume();
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.GATEWAY)
+  void resume();
 
   /**
    * Rebalances this GatewaySender.
    */
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public void rebalance();
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.GATEWAY)
+  void rebalance();
 
   /**
    * Returns whether this GatewaySender is primary or secondary.
    * 
    * @return True if this is the primary, false otherwise.
    */
-  public boolean isPrimary();
+  boolean isPrimary();
 
   /**
    * Returns the number of dispatcher threads working for this <code>GatewaySender</code>.
    */
-  public int getDispatcherThreads();
+  int getDispatcherThreads();
 
   /**
    * Returns the order policy followed while dispatching the events to remote distributed system.
    * Order policy is only relevant when the number of dispatcher threads is greater than one.
    */
 
-  public String getOrderPolicy();
+  String getOrderPolicy();
 
   /**
    * Returns whether the isDiskSynchronous property is set for this GatewaySender.
    * 
    * @return True if the property is set, false otherwise.
    */
-  public boolean isDiskSynchronous();
+  boolean isDiskSynchronous();
 
   /**
    * Returns whether the isParallel property is set for this GatewaySender.
    * 
    * @return True if the property is set, false otherwise.
    */
-  public boolean isParallel();
+  boolean isParallel();
 
   /**
    * Returns the host and port information of GatewayReceiver to which this gateway sender is
    * connected.
    */
-  public String getGatewayReceiver();
+  String getGatewayReceiver();
 
   /**
    * Returns whether this GatewaySender is connected and sending data to a GatewayReceiver.
    */
-  public boolean isConnected();
+  boolean isConnected();
 
   /**
    * Returns number of events which have exceeded the configured alert threshold.
    */
-  public int getEventsExceedingAlertThreshold();
+  int getEventsExceedingAlertThreshold();
 
 
 

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/LockServiceMXBean.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/LockServiceMXBean.java b/geode-core/src/main/java/org/apache/geode/management/LockServiceMXBean.java
index f109022..a62ca49 100644
--- a/geode-core/src/main/java/org/apache/geode/management/LockServiceMXBean.java
+++ b/geode-core/src/main/java/org/apache/geode/management/LockServiceMXBean.java
@@ -35,53 +35,53 @@ public interface LockServiceMXBean {
   /**
    * Returns the name of the lock service.
    */
-  public String getName();
+  String getName();
 
   /**
    * Returns whether this is a distributed LockService.
    *
    * @return True is this is a distributed LockService, false otherwise.
    */
-  public boolean isDistributed();
+  boolean isDistributed();
 
   /**
    * Returns the number of members using this LockService.
    */
-  public int getMemberCount();
+  int getMemberCount();
 
   /**
    * Returns of the name of the member which grants the lock.
    */
-  public String fetchGrantorMember();
+  String fetchGrantorMember();
 
   /**
    * Returns a list of names of the members using this LockService.
    */
-  public String[] getMemberNames();
+  String[] getMemberNames();
 
   /**
    * Returns whether this member is the granter.
    * 
    * @return True if this member is the granter, false otherwise.
    */
-  public boolean isLockGrantor();
+  boolean isLockGrantor();
 
 
   /**
    * Requests that this member become the granter.
    */
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public void becomeLockGrantor();
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE)
+  void becomeLockGrantor();
 
   /**
    * Returns a map of the names of the objects being locked on and the names of the threads holding
    * the locks.
    */
-  public Map<String, String> listThreadsHoldingLock();
+  Map<String, String> listThreadsHoldingLock();
 
   /**
    * Returns a list of names of the locks held by this member's threads.
    */
-  public String[] listHeldLocks();
+  String[] listHeldLocks();
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/MemberMXBean.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/MemberMXBean.java b/geode-core/src/main/java/org/apache/geode/management/MemberMXBean.java
index e2de400..ca7c2a2 100644
--- a/geode-core/src/main/java/org/apache/geode/management/MemberMXBean.java
+++ b/geode-core/src/main/java/org/apache/geode/management/MemberMXBean.java
@@ -20,6 +20,7 @@ import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
+import org.apache.geode.security.ResourcePermission.Target;
 
 /**
  * MBean that provides access to information and management functionality for a
@@ -143,7 +144,7 @@ public interface MemberMXBean {
    * 
    * @param numberOfLines Number of lines to return, up to a maximum of 100.
    */
-  public String showLog(int numberOfLines);
+  String showLog(int numberOfLines);
 
   /**
    * Returns the license string for this member.
@@ -151,15 +152,16 @@ public interface MemberMXBean {
    * @deprecated Removed licensing in 8.0.
    */
   @Deprecated
-  public String viewLicense();
+  String viewLicense();
 
   /**
    * Performs compaction on all of the member's disk stores.
    * 
    * @return A list of names of the disk stores that were compacted.
    */
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
-  public String[] compactAllDiskStores();
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.DISK)
+  String[] compactAllDiskStores();
 
   /**
    * Creates a Manager MBean on this member.
@@ -167,24 +169,24 @@ public interface MemberMXBean {
    * @return True if the Manager MBean was successfully created, false otherwise.
    */
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE)
-  public boolean createManager();
+  boolean createManager();
 
   /**
    * Shuts down the member. This is an asynchronous call and it will return immediately without
    * waiting for a result.
    */
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE)
-  public void shutDownMember();
+  void shutDownMember();
 
   /**
    * Returns JVM metrics.
    */
-  public JVMMetrics showJVMMetrics();
+  JVMMetrics showJVMMetrics();
 
   /**
    * Returns operating system metrics.
    */
-  public OSMetrics showOSMetrics();
+  OSMetrics showOSMetrics();
 
   /**
    * Executes a command on the member.
@@ -222,89 +224,89 @@ public interface MemberMXBean {
    * 
    * @param includeRegionOwned Whether to include disk stores owned by a region.
    */
-  public String[] listDiskStores(boolean includeRegionOwned);
+  String[] listDiskStores(boolean includeRegionOwned);
 
   /**
    * Returns the GemFire specific properties for this member.
    */
-  public GemFireProperties listGemFireProperties();
+  GemFireProperties listGemFireProperties();
 
   /**
    * Returns the name or IP address of the host on which this member is running.
    */
-  public String getHost();
+  String getHost();
 
   /**
    * Returns the name of this member.
    */
-  public String getName();
+  String getName();
 
   /**
    * Returns the ID of this member.
    */
-  public String getId();
+  String getId();
 
   /**
    * Returns the name of the member if it's been set, otherwise the ID.
    */
-  public String getMember();
+  String getMember();
 
   /**
    * Returns the names of the groups this member belongs to.
    */
-  public String[] getGroups();
+  String[] getGroups();
 
   /**
    * Returns the operating system process ID.
    */
-  public int getProcessId();
+  int getProcessId();
 
   /**
    * Returns the status.
    */
-  public String status();
+  String status();
 
   /**
    * Returns the GemFire version.
    */
-  public String getVersion();
+  String getVersion();
 
   /**
    * Returns whether this member is attached to at least one Locator.
    * 
    * @return True if this member is attached to a Locator, false otherwise.
    */
-  public boolean isLocator();
+  boolean isLocator();
 
   /**
    * Returns the number of seconds that this member will wait for a distributed lock.
    */
-  public long getLockTimeout();
+  long getLockTimeout();
 
   /**
    * Returns the number of second that this member will lease a distributed lock.
    */
-  public long getLockLease();
+  long getLockLease();
 
   /**
    * Any long-running GemFire process that was started with "start server" command from GFSH. It
    * returns true even if that process has --disable-default-server=true.
    */
-  public boolean isServer();
+  boolean isServer();
 
   /**
    * Returns whether this member has at least one GatewaySender.
    * 
-   * @return True if this member has at least one GatwaySender, false otherwise.
+   * @return True if this member has at least one GatewaySender, false otherwise.
    */
-  public boolean hasGatewaySender();
+  boolean hasGatewaySender();
 
   /**
    * Returns whether this member is running the Manager service.
    * 
    * @return True if this member is running the Manager service, false otherwise.
    */
-  public boolean isManager();
+  boolean isManager();
 
   /**
    * Returns whether this member has created the Manager service (it may be created, but not
@@ -312,29 +314,29 @@ public interface MemberMXBean {
    * 
    * @return True if this member has created the Manager service, false otherwise.
    */
-  public boolean isManagerCreated();
+  boolean isManagerCreated();
 
   /**
    * Returns whether this member has at least one GatewayReceiver.
    * 
-   * @return True if this member has at least one GatwayReceiver, false otherwise.
+   * @return True if this member has at least one GatewayReceiver, false otherwise.
    */
-  public boolean hasGatewayReceiver();
+  boolean hasGatewayReceiver();
 
   /**
    * Returns the ClassPath.
    */
-  public String getClassPath();
+  String getClassPath();
 
   /**
    * Returns the current time on the member's host.
    */
-  public long getCurrentTime();
+  long getCurrentTime();
 
   /**
    * Returns the number of seconds that this member has been running.
    */
-  public long getMemberUpTime();
+  long getMemberUpTime();
 
   /**
    * Returns the time (as a percentage) that this member's process time with respect to Statistics
@@ -345,393 +347,402 @@ public interface MemberMXBean {
    * the platform it will be shown as -1
    * 
    */
-  public float getCpuUsage();
+  float getCpuUsage();
 
   /**
    * Returns the current size of the heap in megabytes.
    * 
    * @deprecated Please use {@link #getUsedMemory()} instead.
    */
-  public long getCurrentHeapSize();
+  long getCurrentHeapSize();
 
   /**
    * Returns the maximum size of the heap in megabytes.
    * 
    * @deprecated Please use {@link #getMaxMemory()} instead.
    */
-  public long getMaximumHeapSize();
+  long getMaximumHeapSize();
 
   /**
    * Returns the free heap size in megabytes.
    * 
    * @deprecated Please use {@link #getFreeMemory()} instead.
    */
-  public long getFreeHeapSize();
+  long getFreeHeapSize();
 
   /**
    * Returns the maximum size of the heap in megabytes.
    * 
    */
-  public long getMaxMemory();
+  long getMaxMemory();
 
   /**
    * Returns the free heap size in megabytes.
    */
-  public long getFreeMemory();
+  long getFreeMemory();
 
   /**
    * Returns the current size of the heap in megabytes.
    */
-  public long getUsedMemory();
+  long getUsedMemory();
 
   /**
    * Returns the current threads.
    */
-  public String[] fetchJvmThreads();
+  String[] fetchJvmThreads();
 
   /**
    * Returns the maximum number of open file descriptors allowed for the member's host operating
    * system.
    */
-  public long getFileDescriptorLimit();
+  long getFileDescriptorLimit();
 
   /**
    * Returns the current number of open file descriptors.
    */
-  public long getTotalFileDescriptorOpen();
+  long getTotalFileDescriptorOpen();
 
   /**
    * Returns the number of Regions present in the Cache.
    */
-  public int getTotalRegionCount();
+  int getTotalRegionCount();
 
   /**
    * Returns the number of Partition Regions present in the Cache.
    */
-  public int getPartitionRegionCount();
+  int getPartitionRegionCount();
 
   /**
    * Returns a list of all Region names.
    */
-  public String[] listRegions();
+  String[] listRegions();
 
 
   /**
    * Returns a list of all disk stores, including those owned by a Region.
    */
-  public String[] getDiskStores();
+  String[] getDiskStores();
 
   /**
    * Returns a list of all root Region names.
    */
-  public String[] getRootRegionNames();
+  String[] getRootRegionNames();
 
   /**
    * Returns the total number of entries in all regions.
    */
-  public int getTotalRegionEntryCount();
+  int getTotalRegionEntryCount();
 
   /**
    * Returns the total number of buckets.
    */
-  public int getTotalBucketCount();
+  int getTotalBucketCount();
 
   /**
    * Returns the number of buckets for which this member is the primary holder.
    */
-  public int getTotalPrimaryBucketCount();
+  int getTotalPrimaryBucketCount();
 
   /**
    * Returns the cache get average latency.
    */
-  public long getGetsAvgLatency();
+  long getGetsAvgLatency();
 
   /**
    * Returns the cache put average latency.
    */
-  public long getPutsAvgLatency();
+  long getPutsAvgLatency();
 
   /**
    * Returns the cache putAll average latency.
    */
-  public long getPutAllAvgLatency();
+  long getPutAllAvgLatency();
 
   /**
    * Returns the number of times that a cache miss occurred for all regions.
    */
-  public int getTotalMissCount();
+  int getTotalMissCount();
 
   /**
    * Returns the number of times that a hit occurred for all regions.
    */
-  public int getTotalHitCount();
+  int getTotalHitCount();
 
   /**
    * Returns the number of gets per second.
    */
-  public float getGetsRate();
+  float getGetsRate();
 
   /**
    * Returns the number of puts per second. Only includes puts done explicitly on this member's
    * cache, not those pushed from another member.
    */
-  public float getPutsRate();
+  float getPutsRate();
 
   /**
    * Returns the number of putAlls per second.
    */
-  public float getPutAllRate();
+  float getPutAllRate();
 
   /**
    * Returns the number of creates per second.
    */
-  public float getCreatesRate();
+  float getCreatesRate();
 
   /**
    * Returns the number of destroys per second.
    */
-  public float getDestroysRate();
+  float getDestroysRate();
 
   /**
    * Returns the average latency of a call to a CacheWriter.
    */
-  public long getCacheWriterCallsAvgLatency();
+  long getCacheWriterCallsAvgLatency();
 
   /**
    * Returns the average latency of a call to a CacheListener.
    */
-  public long getCacheListenerCallsAvgLatency();
+  long getCacheListenerCallsAvgLatency();
 
   /**
    * Returns the total number of times that a load on this cache has completed, as a result of
    * either a local get or a remote net load.
    */
-  public int getTotalLoadsCompleted();
+  int getTotalLoadsCompleted();
 
   /**
    * Returns the average latency of a load.
    */
-  public long getLoadsAverageLatency();
+  long getLoadsAverageLatency();
 
   /**
    * Returns the total number of times the a network load initiated by this cache has completed.
    */
-  public int getTotalNetLoadsCompleted();
+  int getTotalNetLoadsCompleted();
 
   /**
    * Returns the net load average latency.
    */
-  public long getNetLoadsAverageLatency();
+  long getNetLoadsAverageLatency();
 
   /**
    * Returns the total number of times that a network search initiated by this cache has completed.
    */
-  public int getTotalNetSearchCompleted();
+  int getTotalNetSearchCompleted();
 
   /**
    * Returns the net search average latency.
    */
-  public long getNetSearchAverageLatency();
+  long getNetSearchAverageLatency();
 
   /**
    * Returns the current number of disk tasks (op-log compaction, asynchronous recovery, etc.) that
    * are waiting for a thread to run.
    */
-  public int getTotalDiskTasksWaiting();
+  int getTotalDiskTasksWaiting();
 
   /**
    * Returns the average number of bytes per second sent.
    */
-  public float getBytesSentRate();
+  float getBytesSentRate();
 
   /**
    * Returns the average number of bytes per second received.
    */
-  public float getBytesReceivedRate();
+  float getBytesReceivedRate();
 
   /**
    * Returns a list of IDs for all connected gateway receivers.
    */
-  public String[] listConnectedGatewayReceivers();
+  String[] listConnectedGatewayReceivers();
 
   /**
    * Returns a list of IDs for all gateway senders.
    */
-  public String[] listConnectedGatewaySenders();
+  String[] listConnectedGatewaySenders();
 
   /**
    * Returns the number of currently executing functions.
    */
-  public int getNumRunningFunctions();
+  int getNumRunningFunctions();
 
   /**
    * Returns the average function execution rate.
    */
-  public float getFunctionExecutionRate();
+  float getFunctionExecutionRate();
 
   /**
-   * Returns the number of currently executing functions that will return resutls.
+   * Returns the number of currently executing functions that will return results.
    */
-  public int getNumRunningFunctionsHavingResults();
+  int getNumRunningFunctionsHavingResults();
 
   /**
    * Returns the number of current transactions.
    */
-  public int getTotalTransactionsCount();
+  int getTotalTransactionsCount();
 
   /**
    * Returns the average commit latency in nanoseconds .
    */
-  public long getTransactionCommitsAvgLatency();
+  long getTransactionCommitsAvgLatency();
 
   /**
    * Returns the number of committed transactions.
    */
-  public int getTransactionCommittedTotalCount();
+  int getTransactionCommittedTotalCount();
 
   /**
    * Returns the number of transactions that were rolled back.
    */
-  public int getTransactionRolledBackTotalCount();
+  int getTransactionRolledBackTotalCount();
 
   /**
    * Returns the average number of transactions committed per second.
    */
-  public float getTransactionCommitsRate();
+  float getTransactionCommitsRate();
 
 
   /**
    * Returns the number of bytes reads per second from all the disks of the member.
    */
-  public float getDiskReadsRate();
+  float getDiskReadsRate();
 
   /**
    * Returns the number of bytes written per second to disk to all the disks of the member.
    */
-  public float getDiskWritesRate();
+  float getDiskWritesRate();
 
   /**
    * Returns the average disk flush latency time in nanoseconds.
    */
-  public long getDiskFlushAvgLatency();
+  long getDiskFlushAvgLatency();
 
   /**
    * Returns the number of backups currently in progress for all disk stores.
    */
-  public int getTotalBackupInProgress();
+  int getTotalBackupInProgress();
 
   /**
    * Returns the number of backups that have been completed.
    */
-  public int getTotalBackupCompleted();
+  int getTotalBackupCompleted();
 
   /**
    * Returns the number of threads waiting for a lock.
    */
-  public int getLockWaitsInProgress();
+  int getLockWaitsInProgress();
 
   /**
    * Returns the amount of time (in milliseconds) spent waiting for a lock.
    */
-  public long getTotalLockWaitTime();
+  long getTotalLockWaitTime();
 
   /**
    * Returns the number of lock services in use.
    */
-  public int getTotalNumberOfLockService();
+  int getTotalNumberOfLockService();
 
   /**
    * Returns the number of locks for which this member is a granter.
    */
-  public int getTotalNumberOfGrantors();
+  int getTotalNumberOfGrantors();
 
   /**
    * Returns the number of lock request queues in use by this member.
    */
-  public int getLockRequestQueues();
+  int getLockRequestQueues();
 
   /**
    * Returns the entry eviction rate as triggered by the LRU policy.
    */
-  public float getLruEvictionRate();
+  float getLruEvictionRate();
 
   /**
    * Returns the rate of entries destroyed either by destroy cache operations or eviction.
    */
-  public float getLruDestroyRate();
+  float getLruDestroyRate();
+
+  /**
+   * Returns the number of initial images in progress.
+   * 
+   * @deprecated as typo in name has been corrected: use
+   *             {@link MemberMXBean#getInitialImagesInProgress} instead.
+   */
+  @Deprecated
+  int getInitialImagesInProgres();
 
   /**
    * Returns the number of initial images in progress.
    */
-  public int getInitialImagesInProgres();
+  int getInitialImagesInProgress();
 
   /**
    * Returns the total amount of time spent performing a "get initial image" operation when creating
    * a region.
    */
-  public long getInitialImageTime();
+  long getInitialImageTime();
 
   /**
    * Return the number of keys received while performing a "get initial image" operation when
    * creating a region.
    */
-  public int getInitialImageKeysReceived();
+  int getInitialImageKeysReceived();
 
   /**
    * Returns the average time (in nanoseconds) spent deserializing objects. Includes
    * deserializations that result in a PdxInstance.
    */
-  public long getDeserializationAvgLatency();
+  long getDeserializationAvgLatency();
 
   /**
    * Returns the average latency (in nanoseconds) spent deserializing objects. Includes
    * deserializations that result in a PdxInstance.
    */
-  public long getDeserializationLatency();
+  long getDeserializationLatency();
 
   /**
    * Returns the instantaneous rate of deserializing objects. Includes deserializations that result
    * in a PdxInstance.
    */
-  public float getDeserializationRate();
+  float getDeserializationRate();
 
   /**
    * Returns the average time (in nanoseconds) spent serializing objects. Includes serializations
    * that result in a PdxInstance.
    */
-  public long getSerializationAvgLatency();
+  long getSerializationAvgLatency();
 
   /**
    * Returns the average latency (in nanoseconds) spent serializing objects. Includes serializations
    * that result in a PdxInstance.
    */
-  public long getSerializationLatency();
+  long getSerializationLatency();
 
   /**
    * Returns the instantaneous rate of serializing objects. Includes serializations that result in a
    * PdxInstance.
    */
-  public float getSerializationRate();
+  float getSerializationRate();
 
   /**
    * Returns the instantaneous rate of PDX instance deserialization.
    */
-  public float getPDXDeserializationRate();
+  float getPDXDeserializationRate();
 
   /**
    * Returns the average time, in seconds, spent deserializing PDX instanced.
    */
-  public long getPDXDeserializationAvgLatency();
+  long getPDXDeserializationAvgLatency();
 
   /**
    * Returns the total number of bytes used on all disks.
    */
-  public long getTotalDiskUsage();
+  long getTotalDiskUsage();
 
   /**
    * Returns the number of threads in use.
    */
-  public int getNumThreads();
+  int getNumThreads();
 
   /**
    * Returns the system load average for the last minute. The system load average is the sum of the
@@ -742,99 +753,99 @@ public interface MemberMXBean {
    * 
    * @return The load average or a negative value if one is not available.
    */
-  public double getLoadAverage();
+  double getLoadAverage();
 
   /**
    * Returns the number of times garbage collection has occurred.
    */
-  public long getGarbageCollectionCount();
+  long getGarbageCollectionCount();
 
   /**
    * Returns the amount of time (in milliseconds) spent on garbage collection.
    */
-  public long getGarbageCollectionTime();
+  long getGarbageCollectionTime();
 
   /**
    * Returns the average number of reads per second.
    */
-  public float getAverageReads();
+  float getAverageReads();
 
   /**
    * Returns the average writes per second, including both put and putAll operations.
    */
-  public float getAverageWrites();
+  float getAverageWrites();
 
   /**
    * Returns the number JVM pauses (which may or may not include full garbage collection pauses)
    * detected by GemFire.
    */
-  public long getJVMPauses();
+  long getJVMPauses();
 
 
   /**
    * Returns the underlying host's current cpuActive percentage
    */
-  public int getHostCpuUsage();
+  int getHostCpuUsage();
 
   /**
    * 
    * Returns true if a cache server is running on this member and able server requests from GemFire
    * clients
    */
-  public boolean isCacheServer();
+  boolean isCacheServer();
 
   /**
    * Returns the redundancy-zone of the member;
    */
-  public String getRedundancyZone();
+  String getRedundancyZone();
 
   /**
    * Returns current number of cache rebalance operations being directed by this process.
    */
-  public int getRebalancesInProgress();
+  int getRebalancesInProgress();
 
   /**
    * Returns current number of threads waiting for a reply.
    */
-  public int getReplyWaitsInProgress();
+  int getReplyWaitsInProgress();
 
   /**
    * Returns total number of times waits for a reply have completed.
    */
-  public int getReplyWaitsCompleted();
+  int getReplyWaitsCompleted();
 
   /**
    * The current number of nodes in this distributed system visible to this member.
    */
-  public int getVisibleNodes();
+  int getVisibleNodes();
 
   /**
    * Returns the number of off heap objects.
    */
-  public int getOffHeapObjects();
+  int getOffHeapObjects();
 
   /**
    * Returns the size of the maximum configured off-heap memory in bytes.
    */
-  public long getOffHeapMaxMemory();
+  long getOffHeapMaxMemory();
 
   /**
    * Returns the size of available (or unallocated) off-heap memory in bytes.
    */
-  public long getOffHeapFreeMemory();
+  long getOffHeapFreeMemory();
 
   /**
    * Returns the size of utilized off-heap memory in bytes.
    */
-  public long getOffHeapUsedMemory();
+  long getOffHeapUsedMemory();
 
   /**
    * Returns the percentage of off-heap memory fragmentation.
    */
-  public int getOffHeapFragmentation();
+  int getOffHeapFragmentation();
 
   /**
-   * Returns the total time spent compacting in millseconds.
+   * Returns the total time spent compacting in milliseconds.
    */
-  public long getOffHeapCompactionTime();
+  long getOffHeapCompactionTime();
 }


[07/46] geode git commit: GEODE-2601: Fixing banner being logged twice during locator startup.

Posted by zh...@apache.org.
GEODE-2601: Fixing banner being logged twice during locator startup.


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

Branch: refs/heads/feature/GEM-1483
Commit: 2d3e05ecedf724af8d413f50567afc7f9a87e343
Parents: 3154424
Author: YehEmily <em...@gmail.com>
Authored: Mon Jun 12 13:55:24 2017 -0700
Committer: Ken Howe <kh...@pivotal.io>
Committed: Mon Jun 19 09:52:13 2017 -0700

----------------------------------------------------------------------
 .../internal/InternalDistributedSystem.java     | 24 ++++++++++++
 .../distributed/internal/InternalLocator.java   | 41 ++++++++++----------
 .../internal/logging/LogWriterFactory.java      | 20 ++++------
 3 files changed, 53 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/2d3e05ec/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
index d77e8b9..4ed58af 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
@@ -18,6 +18,30 @@ package org.apache.geode.distributed.internal;
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+import java.lang.reflect.Array;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.logging.log4j.Logger;
+
 import org.apache.geode.CancelCriterion;
 import org.apache.geode.CancelException;
 import org.apache.geode.ForcedDisconnectException;

http://git-wip-us.apache.org/repos/asf/geode/blob/2d3e05ec/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
index ae548c4..3ff27ea 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
@@ -18,7 +18,24 @@ import static org.apache.geode.distributed.ConfigurationProperties.BIND_ADDRESS;
 import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE;
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 
+import java.io.File;
+import java.io.IOException;
+import java.net.ConnectException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
 import org.apache.commons.lang.StringUtils;
+import org.apache.logging.log4j.Logger;
+
 import org.apache.geode.CancelException;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.GemFireCache;
@@ -65,22 +82,6 @@ import org.apache.geode.management.internal.configuration.handlers.SharedConfigu
 import org.apache.geode.management.internal.configuration.messages.ConfigurationRequest;
 import org.apache.geode.management.internal.configuration.messages.SharedConfigurationStatusRequest;
 import org.apache.geode.management.internal.configuration.messages.SharedConfigurationStatusResponse;
-import org.apache.logging.log4j.Logger;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.ConnectException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
  * Provides the implementation of a distribution {@code Locator} as well as internal-only
@@ -469,17 +470,17 @@ public class InternalLocator extends Locator implements ConnectListener {
         LogWriterAppenders.getOrCreateAppender(LogWriterAppenders.Identifier.SECURITY, true, false,
             this.config, false);
 
-      } else {
-        // do not create a LogWriterAppender for security -- let it go through to logWriterAppender
       }
+        // do not create a LogWriterAppender for security -- let it go through to logWriterAppender
     }
 
     // LOG: create LogWriters for GemFireTracer (or use whatever was passed in)
     if (logWriter == null) {
       logWriter = LogWriterFactory.createLogWriterLogger(false, false, this.config,
-          !startDistributedSystem);
-      if (logger.isDebugEnabled())
+          false);
+      if (logger.isDebugEnabled()) {
         logger.debug("LogWriter for locator is created.");
+      }
     }
 
     if (securityLogWriter == null) {

http://git-wip-us.apache.org/repos/asf/geode/blob/2d3e05ec/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterFactory.java b/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterFactory.java
index c4fecfd..4202afd 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterFactory.java
@@ -14,7 +14,7 @@
  */
 package org.apache.geode.internal.logging;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
 
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
@@ -79,16 +79,13 @@ public class LogWriterFactory {
     }
 
     // log the banner
-    if (!Boolean.getBoolean(InternalLocator.INHIBIT_DM_BANNER)) {
-      if (InternalDistributedSystem.getReconnectAttemptCounter() == 0 // avoid filling up logs
-                                                                      // during auto-reconnect
-          && !isSecure // && !isLoner /* do this on a loner to fix bug 35602 */
-      ) {
-        // LOG:CONFIG:
-        logger.info(LogMarker.CONFIG, Banner.getString(null));
-      }
-      System.setProperty(InternalLocator.INHIBIT_DM_BANNER, "true"); // Ensure no more banners will
-                                                                     // be logged
+    if (!Boolean.getBoolean(InternalLocator.INHIBIT_DM_BANNER)
+        && InternalDistributedSystem.getReconnectAttemptCounter() == 0 // avoid filling up logs
+                                                                       // during auto-reconnect
+        && !isSecure // && !isLoner /* do this on a loner to fix bug 35602 */
+        && logConfig) {
+      // LOG:CONFIG:
+      logger.info(LogMarker.CONFIG, Banner.getString(null));
     } else {
       logger.debug("skipping banner - " + InternalLocator.INHIBIT_DM_BANNER + " is set to true");
     }
@@ -101,7 +98,6 @@ public class LogWriterFactory {
               LocalizedStrings.InternalDistributedSystem_STARTUP_CONFIGURATIONN_0,
               config.toLoggerString()));
     }
-
     return logger;
   }
 }


[45/46] geode git commit: GEODE-1958: Rolling back changes to decrypt method

Posted by zh...@apache.org.
GEODE-1958: Rolling back changes to decrypt method

* this closes #600


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

Branch: refs/heads/feature/GEM-1483
Commit: 137ced6bea482209efe5db7d87b58edefd9b7222
Parents: e1c6c3a
Author: YehEmily <em...@gmail.com>
Authored: Mon Jun 26 08:55:13 2017 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Mon Jun 26 17:23:32 2017 -0700

----------------------------------------------------------------------
 .../geode/internal/util/PasswordUtil.java       | 49 ++++++--------------
 1 file changed, 15 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/137ced6b/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java b/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
index 5cc3bcd..ac0b845 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/util/PasswordUtil.java
@@ -18,24 +18,8 @@ import javax.crypto.Cipher;
 import javax.crypto.spec.SecretKeySpec;
 
 /**
- * Generates an encrypted password, used by the gemfire encrypt-password command. Makes use of
- * Blowfish algorithm to encrypt/decrypt password string
- * 
- * <p>
- * This shows a sample command invocation and output (assuming password is the actual password for
- * the datasource): <br>
- * <br>
- * bash-2.05$ $GEMFIRE/bin/gemfire encrypt-password password<br>
- * Using system directory "/home/users/jpearson/gemfire/defaultSystem".<br>
- * Encrypted to 83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a <br>
- * <br>
- * Copy the output from the gemfire command to the cache.xml file as the value of the password
- * attribute of the jndi-binding tag embedded in encrypted(), just like a method parameter.<br>
- * Enter it as encrypted, in this format:
- * password="encrypted(83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a)"<br>
- * To use a non-encrypted password, put the actual password as the value of the password attribute
- * of the jndi-binding tag, like this: password="password" <br>
- * 
+ * Makes use of Blowfish algorithm to decrypt a pre-encrypted password string. As of June 2017, no
+ * longer supports encrypting a password. However, decrypting still works.
  */
 public class PasswordUtil {
 
@@ -44,28 +28,25 @@ public class PasswordUtil {
   /**
    * Decrypts an encrypted password string.
    *
-   * @param password String to be decrypted
+   * @param password String to be decrypted (format: `encrypted(password_to_decrypt)`)
    * @return String decrypted String
    */
   @Deprecated
   public static String decrypt(String password) {
-    String toDecrypt;
     if (password.startsWith("encrypted(") && password.endsWith(")")) {
-      toDecrypt = password.substring(10, password.length() - 1);
-    } else {
-      toDecrypt = password;
+      byte[] decrypted;
+      try {
+        String toDecrypt = password.substring(10, password.length() - 1);
+        SecretKeySpec key = new SecretKeySpec(init, "Blowfish");
+        Cipher cipher = Cipher.getInstance("Blowfish");
+        cipher.init(Cipher.DECRYPT_MODE, key);
+        decrypted = cipher.doFinal(hexStringToByteArray(toDecrypt));
+        return new String(decrypted);
+      } catch (Exception e) {
+        e.printStackTrace();
+      }
     }
-    byte[] decrypted;
-    try {
-      SecretKeySpec key = new SecretKeySpec(init, "Blowfish");
-      Cipher cipher = Cipher.getInstance("Blowfish");
-      cipher.init(Cipher.DECRYPT_MODE, key);
-      decrypted = cipher.doFinal(hexStringToByteArray(toDecrypt));
-      return new String(decrypted);
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
-    return toDecrypt;
+    return password;
   }
 
   private static byte[] hexStringToByteArray(String s) {


[11/46] geode git commit: Merge branch 'feature/GEODE-3071' into develop

Posted by zh...@apache.org.
Merge branch 'feature/GEODE-3071' into develop


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

Branch: refs/heads/feature/GEM-1483
Commit: 80667f30ef66d52987235374f3c95f6a39e0cd78
Parents: 8db7862 dba7dcd
Author: Jens Deppe <jd...@pivotal.io>
Authored: Mon Jun 19 14:22:22 2017 -0700
Committer: Jens Deppe <jd...@pivotal.io>
Committed: Mon Jun 19 14:22:22 2017 -0700

----------------------------------------------------------------------
 build.gradle         |   7 ++++
 gradle.properties    |   7 ++++
 gradle/docker.gradle | 100 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 114 insertions(+)
----------------------------------------------------------------------



[08/46] geode git commit: GEODE-2601: Updated based on feedback

Posted by zh...@apache.org.
GEODE-2601: Updated based on feedback

This closes #582


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

Branch: refs/heads/feature/GEM-1483
Commit: 87c26be495de5a23290231e97826cb434277c66b
Parents: 2d3e05e
Author: YehEmily <em...@gmail.com>
Authored: Fri Jun 16 09:06:56 2017 -0700
Committer: Ken Howe <kh...@pivotal.io>
Committed: Mon Jun 19 10:05:12 2017 -0700

----------------------------------------------------------------------
 .../geode/distributed/internal/InternalDistributedSystem.java  | 3 +--
 .../org/apache/geode/distributed/internal/InternalLocator.java | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/87c26be4/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
index 4ed58af..1572355 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
@@ -2189,9 +2189,8 @@ public class InternalDistributedSystem extends DistributedSystem
    * @param resource the actual resource object.
    */
   private void notifyResourceEventListeners(ResourceEvent event, Object resource) {
-    for (Iterator<ResourceEventsListener> iter = resourceListeners.iterator(); iter.hasNext();) {
+    for (ResourceEventsListener listener : resourceListeners) {
       try {
-        ResourceEventsListener listener = iter.next();
         listener.handleEvent(event, resource);
       } catch (CancelException e) {
         // ignore

http://git-wip-us.apache.org/repos/asf/geode/blob/87c26be4/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
index 3ff27ea..6eaaec2 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
@@ -469,15 +469,13 @@ public class InternalLocator extends Locator implements ConnectListener {
         // if security-log-file then create securityLogWriterAppender
         LogWriterAppenders.getOrCreateAppender(LogWriterAppenders.Identifier.SECURITY, true, false,
             this.config, false);
-
       }
-        // do not create a LogWriterAppender for security -- let it go through to logWriterAppender
+      // do not create a LogWriterAppender for security -- let it go through to logWriterAppender
     }
 
     // LOG: create LogWriters for GemFireTracer (or use whatever was passed in)
     if (logWriter == null) {
-      logWriter = LogWriterFactory.createLogWriterLogger(false, false, this.config,
-          false);
+      logWriter = LogWriterFactory.createLogWriterLogger(false, false, this.config, false);
       if (logger.isDebugEnabled()) {
         logger.debug("LogWriter for locator is created.");
       }


[16/46] geode git commit: GEODE-3104 : correct help string to use --include-locators

Posted by zh...@apache.org.
GEODE-3104 : correct help string to use --include-locators

* this closes #595


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

Branch: refs/heads/feature/GEM-1483
Commit: b517ef8ddb4613729157c4e4ba6c3e83ae2dfc2c
Parents: 7df5af3
Author: Amey Barve <ab...@apache.org>
Authored: Wed Jun 21 18:27:01 2017 +0530
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Wed Jun 21 08:16:04 2017 -0700

----------------------------------------------------------------------
 .../org/apache/geode/management/internal/cli/i18n/CliStrings.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/b517ef8d/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
index 0829495..bdf5cff 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
@@ -2063,7 +2063,7 @@ public class CliStrings {
   public static final String SHUTDOWN__MSG__CAN_NOT_SHUTDOWN_WITHIN_TIMEOUT =
       "Could not shutdown within timeout. Shutdown will continue in background";
   public static final String SHUTDOWN__MSG__NO_DATA_NODE_FOUND =
-      "No data node found for stopping. Please specify --shutdown-locators option if you want locators to be stopped";
+      "No data node found for stopping. Please specify --include-locators option if you want locators to be stopped";
 
   public static final String SHUTDOWN_TIMEDOUT =
       "Shutdown command timedout. Please manually check node status";


[46/46] geode git commit: GEODE-3055: The old primary's the shadow bucket is not initialized when rebalance remove it. Thus the new primary candidate can never initialize from it. The fix is to wait until new primary exists before remove the old primary'

Posted by zh...@apache.org.
GEODE-3055: The old primary's the shadow bucket is not
initialized when rebalance remove it. Thus the new primary candidate can
never initialize from it. The fix is to wait until new primary exists before
remove the old primary's bucket in rebalance.


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

Branch: refs/heads/feature/GEM-1483
Commit: 1ef7d2b6a80880a1bd5ac58c5c518a842825ae13
Parents: 137ced6
Author: zhouxh <gz...@pivotal.io>
Authored: Thu Jun 8 14:52:56 2017 -0700
Committer: zhouxh <gz...@pivotal.io>
Committed: Mon Jun 26 21:56:46 2017 -0700

----------------------------------------------------------------------
 .../cache/PartitionedRegionDataStore.java       | 58 +++++++++++++++++++-
 1 file changed, 56 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/1ef7d2b6/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegionDataStore.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegionDataStore.java b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegionDataStore.java
index 7cef0a5..798436d 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegionDataStore.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegionDataStore.java
@@ -1417,6 +1417,39 @@ public class PartitionedRegionDataStore implements HasCachePerfStats {
     }
   }
 
+  public boolean isRemotePrimaryReadyForColocatedChildren(int bucketId) {
+    boolean isRemotePrimaryReady = true;
+    InternalDistributedMember myId =
+        this.partitionedRegion.getDistributionManager().getDistributionManagerId();
+
+    List<PartitionedRegion> colocatedChildPRs =
+        ColocationHelper.getColocatedChildRegions(this.partitionedRegion);
+    if (colocatedChildPRs != null) {
+      for (PartitionedRegion pr : colocatedChildPRs) {
+        InternalDistributedMember primaryChild = pr.getBucketPrimary(bucketId);
+        if (logger.isDebugEnabled()) {
+          logger.debug("Checking colocated child bucket " + pr + ", bucketId=" + bucketId
+              + ", primary is " + primaryChild);
+        }
+        if (primaryChild == null || myId.equals(primaryChild)) {
+          if (logger.isDebugEnabled()) {
+            logger.debug("Colocated bucket region " + pr + " " + bucketId
+                + " does not have a remote primary yet. Not to remove.");
+          }
+          return false;
+        } else {
+          if (logger.isDebugEnabled()) {
+            logger
+                .debug(pr + " bucketId=" + bucketId + " has remote primary, checking its children");
+          }
+          isRemotePrimaryReady = isRemotePrimaryReady
+              && pr.getDataStore().isRemotePrimaryReadyForColocatedChildren(bucketId);
+        }
+      }
+    }
+    return isRemotePrimaryReady;
+  }
+
   /**
    * Removes a redundant bucket hosted by this data store. The rebalancer invokes this method
    * directly or sends this member a message to invoke it.
@@ -1471,7 +1504,11 @@ public class PartitionedRegionDataStore implements HasCachePerfStats {
 
       }
 
+      PartitionedRegion leader = ColocationHelper.getLeaderRegion(this.partitionedRegion);
+      boolean isLeader = leader.equals(this.partitionedRegion);
       BucketAdvisor bucketAdvisor = bucketRegion.getBucketAdvisor();
+      InternalDistributedMember myId =
+          this.partitionedRegion.getDistributionManager().getDistributionManagerId();
       Lock writeLock = bucketAdvisor.getActiveWriteLock();
 
       // Fix for 43613 - don't remove the bucket
@@ -1484,6 +1521,25 @@ public class PartitionedRegionDataStore implements HasCachePerfStats {
           return false;
         }
 
+        if (isLeader) {
+          if (!isRemotePrimaryReadyForColocatedChildren(bucketId)) {
+            return false;
+          }
+
+          InternalDistributedMember primary = bucketAdvisor.getPrimary();
+          if (primary == null || myId.equals(primary)) {
+            if (logger.isDebugEnabled()) {
+              logger.debug("Bucket region " + bucketRegion
+                  + " does not have a remote primary yet. Not to remove.");
+            }
+            return false;
+          }
+
+          if (logger.isDebugEnabled()) {
+            logger.debug("Bucket region " + bucketRegion + " has primary at " + primary);
+          }
+        }
+
         // recurse down to each tier of children to remove first
         removeBucketForColocatedChildren(bucketId, forceRemovePrimary);
 
@@ -1513,8 +1569,6 @@ public class PartitionedRegionDataStore implements HasCachePerfStats {
       // because it won't block write operations while we're trying to acquire
       // the activePrimaryMoveLock
       InternalDistributedMember primary = bucketAdvisor.getPrimary();
-      InternalDistributedMember myId =
-          this.partitionedRegion.getDistributionManager().getDistributionManagerId();
       if (!myId.equals(primary)) {
         StateFlushOperation flush = new StateFlushOperation(bucketRegion);
         int executor = DistributionManager.WAITING_POOL_EXECUTOR;


[27/46] geode git commit: GEODE-2919: Provide finer grained security

Posted by zh...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemMBean.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemMBean.java b/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemMBean.java
index c45da73..28edbf6 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemMBean.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/beans/DistributedSystemMBean.java
@@ -14,6 +14,12 @@
  */
 package org.apache.geode.management.internal.beans;
 
+import java.util.Map;
+
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.ObjectName;
+
+import org.apache.geode.internal.security.SecurityServiceFactory;
 import org.apache.geode.management.DiskBackupStatus;
 import org.apache.geode.management.DiskMetrics;
 import org.apache.geode.management.DistributedSystemMXBean;
@@ -22,10 +28,9 @@ import org.apache.geode.management.JVMMetrics;
 import org.apache.geode.management.NetworkMetrics;
 import org.apache.geode.management.OSMetrics;
 import org.apache.geode.management.PersistentMemberDetails;
-
-import java.util.Map;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.ObjectName;
+import org.apache.geode.security.ResourcePermission.Operation;
+import org.apache.geode.security.ResourcePermission.Resource;
+import org.apache.geode.security.ResourcePermission.Target;
 
 /**
  * Distributed System MBean
@@ -48,8 +53,9 @@ public class DistributedSystemMBean extends NotificationBroadcasterSupport
   @Override
   public DiskBackupStatus backupAllMembers(String targetDirPath, String baselineDirPath)
       throws Exception {
+    SecurityServiceFactory.findSecurityService().authorize(Resource.CLUSTER, Operation.WRITE,
+        Target.DISK);
     return bridge.backupAllMembers(targetDirPath, baselineDirPath);
-
   }
 
   @Override
@@ -60,7 +66,6 @@ public class DistributedSystemMBean extends NotificationBroadcasterSupport
   @Override
   public String[] listCacheServers() {
     return bridge.listCacheServers();
-
   }
 
 
@@ -243,7 +248,7 @@ public class DistributedSystemMBean extends NotificationBroadcasterSupport
   }
 
   @Override
-  public boolean revokeMissingDiskStores(final String diskStoreId) throws Exception {
+  public boolean revokeMissingDiskStores(final String diskStoreId) {
     return bridge.revokeMissingDiskStores(diskStoreId);
   }
 
@@ -433,6 +438,6 @@ public class DistributedSystemMBean extends NotificationBroadcasterSupport
 
   @Override
   public void setQueryCollectionsDepth(int queryCollectionsDepth) {
-    bridge.setQueryCollectionsDepth(queryCollectionsDepth);;
+    bridge.setQueryCollectionsDepth(queryCollectionsDepth);
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/beans/MemberMBean.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/beans/MemberMBean.java b/geode-core/src/main/java/org/apache/geode/management/internal/beans/MemberMBean.java
index 9d717d0..271dce1 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/beans/MemberMBean.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/beans/MemberMBean.java
@@ -148,7 +148,12 @@ public class MemberMBean extends NotificationBroadcasterSupport implements Membe
 
   @Override
   public int getInitialImagesInProgres() {
-    return bridge.getInitialImagesInProgres();
+    return getInitialImagesInProgress();
+  }
+
+  @Override
+  public int getInitialImagesInProgress() {
+    return bridge.getInitialImagesInProgress();
   }
 
 

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/beans/MemberMBeanBridge.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/beans/MemberMBeanBridge.java b/geode-core/src/main/java/org/apache/geode/management/internal/beans/MemberMBeanBridge.java
index 516b97d..dd905eb 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/beans/MemberMBeanBridge.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/beans/MemberMBeanBridge.java
@@ -14,7 +14,7 @@
  */
 package org.apache.geode.management.internal.beans;
 
-import static org.apache.geode.internal.lang.SystemUtils.*;
+import static org.apache.geode.internal.lang.SystemUtils.getLineSeparator;
 
 import java.io.File;
 import java.io.IOException;
@@ -1341,7 +1341,7 @@ public class MemberMBeanBridge {
     return getMemberLevelStatistic(StatsKey.GET_INITIAL_IMAGE_TIME).longValue();
   }
 
-  public int getInitialImagesInProgres() {
+  public int getInitialImagesInProgress() {
     return getMemberLevelStatistic(StatsKey.GET_INITIAL_IMAGES_INPROGRESS).intValue();
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ClientCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ClientCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ClientCommands.java
index fe27b60..dac12fa 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ClientCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ClientCommands.java
@@ -14,7 +14,19 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
-import org.apache.geode.cache.CacheFactory;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import javax.management.ObjectName;
+
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.cache.InternalCache;
@@ -25,30 +37,16 @@ import org.apache.geode.management.cli.CliMetaData;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.LogWrapper;
-import org.apache.geode.management.internal.cli.functions.ContunuousQueryFunction;
-import org.apache.geode.management.internal.cli.functions.ContunuousQueryFunction.ClientInfo;
+import org.apache.geode.management.internal.cli.functions.ContinuousQueryFunction;
+import org.apache.geode.management.internal.cli.functions.ContinuousQueryFunction.ClientInfo;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.result.CompositeResultData;
 import org.apache.geode.management.internal.cli.result.CompositeResultData.SectionResultData;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
 import org.apache.geode.management.internal.cli.result.TabularResultData;
-import org.apache.geode.management.internal.cli.shell.Gfsh;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.CommandMarker;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import javax.management.ObjectName;
 
 /**
  * @since GemFire 8.0
@@ -59,7 +57,7 @@ public class ClientCommands implements GfshCommand {
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_CLIENT})
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   public Result listClient() {
-    Result result = null;
+    Result result;
 
     try {
       CompositeResultData compositeResultData = ResultBuilder.createCompositeResultData();
@@ -78,7 +76,7 @@ public class ClientCommands implements GfshCommand {
             CliStrings.format(CliStrings.LIST_CLIENT_COULD_NOT_RETRIEVE_SERVER_LIST));
       }
 
-      Map<String, List<String>> clientServerMap = new HashMap<String, List<String>>();
+      Map<String, List<String>> clientServerMap = new HashMap<>();
 
       for (ObjectName objName : cacheServers) {
         CacheServerMXBean serverMbean = service.getMBeanInstance(objName, CacheServerMXBean.class);
@@ -89,16 +87,16 @@ public class ClientCommands implements GfshCommand {
         }
 
 
-        for (String clietName : listOfClient) {
+        for (String clientName : listOfClient) {
           String serverDetails = "member=" + objName.getKeyProperty("member") + ",port="
               + objName.getKeyProperty("port");
-          if (clientServerMap.containsKey(clietName)) {
-            List<String> listServers = clientServerMap.get(clietName);
+          if (clientServerMap.containsKey(clientName)) {
+            List<String> listServers = clientServerMap.get(clientName);
             listServers.add(serverDetails);
           } else {
-            List<String> listServer = new ArrayList<String>();
+            List<String> listServer = new ArrayList<>();
             listServer.add(serverDetails);
-            clientServerMap.put(clietName, listServer);
+            clientServerMap.put(clientName, listServer);
           }
         }
       }
@@ -109,12 +107,10 @@ public class ClientCommands implements GfshCommand {
       }
 
       String memberSeparator = ";  ";
-      Iterator<Entry<String, List<String>>> it = clientServerMap.entrySet().iterator();
 
-      while (it.hasNext()) {
-        Map.Entry<String, List<String>> pairs = (Map.Entry<String, List<String>>) it.next();
-        String client = (String) pairs.getKey();
-        List<String> servers = (List<String>) pairs.getValue();
+      for (Entry<String, List<String>> pairs : clientServerMap.entrySet()) {
+        String client = pairs.getKey();
+        List<String> servers = pairs.getValue();
         StringBuilder serverListForClient = new StringBuilder();
         int serversSize = servers.size();
         int i = 0;
@@ -148,7 +144,7 @@ public class ClientCommands implements GfshCommand {
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   public Result describeClient(@CliOption(key = CliStrings.DESCRIBE_CLIENT__ID, mandatory = true,
       help = CliStrings.DESCRIBE_CLIENT__ID__HELP) String clientId) {
-    Result result = null;
+    Result result;
 
     if (clientId.startsWith("\"")) {
       clientId = clientId.substring(1);
@@ -179,7 +175,7 @@ public class ClientCommands implements GfshCommand {
       for (ObjectName objName : cacheServers) {
         CacheServerMXBean serverMbean = service.getMBeanInstance(objName, CacheServerMXBean.class);
         List<String> listOfClient =
-            new ArrayList<String>(Arrays.asList((String[]) serverMbean.getClientIds()));
+            new ArrayList<>(Arrays.asList((String[]) serverMbean.getClientIds()));
         if (listOfClient.contains(clientId)) {
           if (clientHealthStatus == null) {
             try {
@@ -204,17 +200,17 @@ public class ClientCommands implements GfshCommand {
 
       Set<DistributedMember> dsMembers = CliUtil.getAllMembers(cache);
       String isDurable = null;
-      List<String> primaryServers = new ArrayList<String>();
-      List<String> secondaryServers = new ArrayList<String>();
+      List<String> primaryServers = new ArrayList<>();
+      List<String> secondaryServers = new ArrayList<>();
 
       if (dsMembers.size() > 0) {
-        ContunuousQueryFunction contunuousQueryFunction = new ContunuousQueryFunction();
-        FunctionService.registerFunction(contunuousQueryFunction);
+        ContinuousQueryFunction continuousQueryFunction = new ContinuousQueryFunction();
+        FunctionService.registerFunction(continuousQueryFunction);
         List<?> resultList = (List<?>) CliUtil
-            .executeFunction(contunuousQueryFunction, clientId, dsMembers).getResult();
-        for (int i = 0; i < resultList.size(); i++) {
+            .executeFunction(continuousQueryFunction, clientId, dsMembers).getResult();
+        for (Object aResultList : resultList) {
           try {
-            Object object = resultList.get(i);
+            Object object = aResultList;
             if (object instanceof Throwable) {
               LogWrapper.getInstance().warning(
                   "Exception in Describe Client " + ((Throwable) object).getMessage(),
@@ -261,11 +257,11 @@ public class ClientCommands implements GfshCommand {
       }
     } catch (Exception e) {
       LogWrapper.getInstance()
-          .info("Error in decribe clients. stack trace" + CliUtil.stackTraceAsString(e));
+          .info("Error in describe clients. stack trace" + CliUtil.stackTraceAsString(e));
       result = ResultBuilder.createGemFireErrorResult(CliStrings
           .format(CliStrings.DESCRIBE_CLIENT_COULD_NOT_RETRIEVE_CLIENT_0, e.getMessage()));
     }
-    LogWrapper.getInstance().info("decribe client result " + result);
+    LogWrapper.getInstance().info("describe client result " + result);
     return result;
   }
 
@@ -309,29 +305,27 @@ public class ClientCommands implements GfshCommand {
       Map<String, String> poolStats = clientHealthStatus.getPoolStats();
 
       if (poolStats.size() > 0) {
-        Iterator<Entry<String, String>> it = poolStats.entrySet().iterator();
-        while (it.hasNext()) {
-          Entry<String, String> entry = it.next();
+        for (Entry<String, String> entry : poolStats.entrySet()) {
           TabularResultData poolStatsResultTable =
               sectionResult.addTable("Pool Stats For Pool Name = " + entry.getKey());
           poolStatsResultTable.setHeader("Pool Stats For Pool Name = " + entry.getKey());
           String poolStatsStr = entry.getValue();
           String str[] = poolStatsStr.split(";");
 
-          LogWrapper.getInstance().info("decribe client clientHealthStatus min conn="
+          LogWrapper.getInstance().info("describe client clientHealthStatus min conn="
               + str[0].substring(str[0].indexOf("=") + 1));
-          LogWrapper.getInstance().info("decribe client clientHealthStatus max conn ="
+          LogWrapper.getInstance().info("describe client clientHealthStatus max conn ="
               + str[1].substring(str[1].indexOf("=") + 1));
-          LogWrapper.getInstance().info("decribe client clientHealthStatus redundancy ="
+          LogWrapper.getInstance().info("describe client clientHealthStatus redundancy ="
               + str[2].substring(str[2].indexOf("=") + 1));
-          LogWrapper.getInstance().info("decribe client clientHealthStatus CQs ="
+          LogWrapper.getInstance().info("describe client clientHealthStatus CQs ="
               + str[3].substring(str[3].indexOf("=") + 1));
 
           poolStatsResultTable.accumulate(CliStrings.DESCRIBE_CLIENT_MIN_CONN,
               str[0].substring(str[0].indexOf("=") + 1));
           poolStatsResultTable.accumulate(CliStrings.DESCRIBE_CLIENT_MAX_CONN,
               str[1].substring(str[1].indexOf("=") + 1));
-          poolStatsResultTable.accumulate(CliStrings.DESCRIBE_CLIENT_REDUDANCY,
+          poolStatsResultTable.accumulate(CliStrings.DESCRIBE_CLIENT_REDUNDANCY,
               str[2].substring(str[2].indexOf("=") + 1));
           poolStatsResultTable.accumulate(CliStrings.DESCRIBE_CLIENT_CQs,
               str[3].substring(str[3].indexOf("=") + 1));

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
index b762396..883bfee 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
@@ -19,7 +19,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -79,6 +78,7 @@ import org.apache.geode.management.internal.configuration.domain.XmlEntity;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
+import org.apache.geode.security.ResourcePermission.Target;
 
 /**
  * @since GemFire 7.0
@@ -103,7 +103,8 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
   }
 
   /**
-   * TODO: method createRegion is too complex to analyze
+   * Internally, we also verify the resource operation permissions CLUSTER:WRITE:DISK if the region
+   * is persistent
    */
   @CliCommand(value = CliStrings.CREATE_REGION, help = CliStrings.CREATE_REGION__HELP)
   @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_REGION)
@@ -295,19 +296,20 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
         }
       }
 
+      // Do we prefer to validate or authorize first?
       validateRegionFunctionArgs(cache, regionFunctionArgs);
+      if (isPersistentShortcut(regionFunctionArgs.getRegionShortcut())
+          || isAttributePersistent(regionFunctionArgs.getRegionAttributes())) {
+        getSecurityService().authorize(Resource.CLUSTER, Operation.WRITE, Target.DISK);
+      }
 
       Set<DistributedMember> membersToCreateRegionOn;
       if (groups != null && groups.length != 0) {
         membersToCreateRegionOn = CliUtil.getDistributedMembersByGroup(cache, groups);
         // have only normal members from the group
-        for (Iterator<DistributedMember> it = membersToCreateRegionOn.iterator(); it.hasNext();) {
-          DistributedMember distributedMember = it.next();
-          if (((InternalDistributedMember) distributedMember)
-              .getVmKind() == DistributionManager.LOCATOR_DM_TYPE) {
-            it.remove();
-          }
-        }
+        membersToCreateRegionOn
+            .removeIf(distributedMember -> ((InternalDistributedMember) distributedMember)
+                .getVmKind() == DistributionManager.LOCATOR_DM_TYPE);
       } else {
         membersToCreateRegionOn = CliUtil.getAllNormalMembers(cache);
       }
@@ -340,9 +342,6 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
     } catch (IllegalArgumentException | IllegalStateException e) {
       LogWrapper.getInstance().info(e.getMessage());
       result = ResultBuilder.createUserErrorResult(e.getMessage());
-    } catch (RuntimeException e) {
-      LogWrapper.getInstance().info(e.getMessage(), e);
-      result = ResultBuilder.createGemFireErrorResult(e.getMessage());
     }
     if (xmlEntity.get() != null) {
       persistClusterConfiguration(result,
@@ -424,7 +423,7 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
     Result result;
     AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
 
-    getCache().getSecurityService().authorizeRegionManage(regionPath);
+    getSecurityService().authorizeRegionManage(regionPath);
 
     try {
       InternalCache cache = getCache();
@@ -914,7 +913,7 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
               } // attributes null check
             } // not IllegalArgumentException or other throwable
           } // iterate over list - there should be only one result in the list
-        } // result list is not null or mpty
+        } // result list is not null or empty
       } // regionAssociatedMembers is not-empty
     } // attributes are null because do not exist on local member
 
@@ -1128,4 +1127,20 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
     }
     return foundMembers;
   }
+
+  private boolean isPersistentShortcut(RegionShortcut shortcut) {
+    return shortcut == RegionShortcut.LOCAL_PERSISTENT
+        || shortcut == RegionShortcut.LOCAL_PERSISTENT_OVERFLOW
+        || shortcut == RegionShortcut.PARTITION_PERSISTENT
+        || shortcut == RegionShortcut.PARTITION_PERSISTENT_OVERFLOW
+        || shortcut == RegionShortcut.PARTITION_REDUNDANT_PERSISTENT
+        || shortcut == RegionShortcut.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW
+        || shortcut == RegionShortcut.REPLICATE_PERSISTENT
+        || shortcut == RegionShortcut.REPLICATE_PERSISTENT_OVERFLOW;
+  }
+
+  private boolean isAttributePersistent(RegionAttributes attributes) {
+    return attributes != null && attributes.getDataPolicy() != null
+        && attributes.getDataPolicy().toString().contains("PERSISTENT");
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java
index b2789e3..3f4397b 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DataCommands.java
@@ -14,9 +14,28 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
+import org.apache.shiro.subject.Subject;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.LogWriter;
 import org.apache.geode.cache.CacheClosedException;
 import org.apache.geode.cache.CacheFactory;
@@ -60,24 +79,6 @@ import org.apache.geode.management.internal.cli.shell.Gfsh;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.apache.shiro.subject.Subject;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 
 /**
  * @since GemFire 7.0
@@ -105,10 +106,8 @@ public class DataCommands implements GfshCommand {
   @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
   public Result rebalance(
       @CliOption(key = CliStrings.REBALANCE__INCLUDEREGION,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.REBALANCE__INCLUDEREGION__HELP) String[] includeRegions,
       @CliOption(key = CliStrings.REBALANCE__EXCLUDEREGION,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.REBALANCE__EXCLUDEREGION__HELP) String[] excludeRegions,
       @CliOption(key = CliStrings.REBALANCE__TIMEOUT, unspecifiedDefaultValue = "-1",
           help = CliStrings.REBALANCE__TIMEOUT__HELP) long timeout,
@@ -135,7 +134,7 @@ public class DataCommands implements GfshCommand {
 
     } catch (Exception ex) {
       result = ResultBuilder.createGemFireErrorResult(CliStrings.format(
-          CliStrings.REBALANCE__MSG__EXCEPTION_OCCRED_WHILE_REBALANCING_0, ex.getMessage()));
+          CliStrings.REBALANCE__MSG__EXCEPTION_OCCURRED_WHILE_REBALANCING_0, ex.getMessage()));
     }
     LogWrapper.getInstance().info("Rebalance returning result >>>" + result);
     return result;
@@ -473,12 +472,12 @@ public class DataCommands implements GfshCommand {
     return listMembersId.toString();
   }
 
-  private CompositeResultData toCompositeResultData(CompositeResultData rebalanceResulteData,
+  private CompositeResultData toCompositeResultData(CompositeResultData rebalanceResultData,
       ArrayList<String> rstlist, int index, boolean simulate, InternalCache cache) {
 
     // add only if there are any valid regions in results
     if (rstlist.size() > resultItemCount && StringUtils.isNotEmpty(rstlist.get(resultItemCount))) {
-      TabularResultData table1 = rebalanceResulteData.addSection().addTable("Table" + index);
+      TabularResultData table1 = rebalanceResultData.addSection().addTable("Table" + index);
       String newLine = System.getProperty("line.separator");
       StringBuilder resultStr = new StringBuilder();
       resultStr.append(newLine);
@@ -541,7 +540,7 @@ public class DataCommands implements GfshCommand {
       table1.setHeader(headerText);
       cache.getLogger().info(headerText + resultStr);
     }
-    return rebalanceResulteData;
+    return rebalanceResultData;
   }
 
   private CompositeResultData buildResultForRebalance(CompositeResultData rebalanceResultData,
@@ -739,15 +738,12 @@ public class DataCommands implements GfshCommand {
       @CliOption(key = CliStrings.EXPORT_DATA__REGION, mandatory = true,
           optionContext = ConverterHint.REGION_PATH,
           help = CliStrings.EXPORT_DATA__REGION__HELP) String regionName,
-      @CliOption(key = CliStrings.EXPORT_DATA__FILE,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, mandatory = true,
+      @CliOption(key = CliStrings.EXPORT_DATA__FILE, mandatory = true,
           help = CliStrings.EXPORT_DATA__FILE__HELP) String filePath,
-      @CliOption(key = CliStrings.MEMBER,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
-          optionContext = ConverterHint.MEMBERIDNAME, mandatory = true,
-          help = CliStrings.EXPORT_DATA__MEMBER__HELP) String memberNameOrId) {
+      @CliOption(key = CliStrings.MEMBER, optionContext = ConverterHint.MEMBERIDNAME,
+          mandatory = true, help = CliStrings.EXPORT_DATA__MEMBER__HELP) String memberNameOrId) {
 
-    getCache().getSecurityService().authorizeRegionRead(regionName);
+    getSecurityService().authorizeRegionRead(regionName);
     final DistributedMember targetMember = CliUtil.getDistributedMemberByNameOrId(memberNameOrId);
     Result result;
 
@@ -796,16 +792,14 @@ public class DataCommands implements GfshCommand {
       @CliOption(key = CliStrings.IMPORT_DATA__REGION, optionContext = ConverterHint.REGION_PATH,
           mandatory = true, help = CliStrings.IMPORT_DATA__REGION__HELP) String regionName,
       @CliOption(key = CliStrings.IMPORT_DATA__FILE, mandatory = true,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.IMPORT_DATA__FILE__HELP) String filePath,
       @CliOption(key = CliStrings.MEMBER, mandatory = true,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.IMPORT_DATA__MEMBER__HELP) String memberNameOrId,
       @CliOption(key = CliStrings.IMPORT_DATA__INVOKE_CALLBACKS, unspecifiedDefaultValue = "false",
           help = CliStrings.IMPORT_DATA__INVOKE_CALLBACKS__HELP) boolean invokeCallbacks) {
 
-    getCache().getSecurityService().authorizeRegionWrite(regionName);
+    getSecurityService().authorizeRegionWrite(regionName);
 
     Result result;
 
@@ -1003,7 +997,7 @@ public class DataCommands implements GfshCommand {
           help = CliStrings.LOCATE_ENTRY__RECURSIVE__HELP,
           unspecifiedDefaultValue = "false") boolean recursive) {
 
-    getCache().getSecurityService().authorizeRegionRead(regionPath, key);
+    getSecurityService().authorizeRegionRead(regionPath, key);
 
     DataCommandResult dataResult;
 

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java
index 9b79e1d..e502154 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommands.java
@@ -15,8 +15,17 @@
 package org.apache.geode.management.internal.cli.commands;
 
 import static org.apache.commons.io.FileUtils.ONE_MB;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.text.DecimalFormat;
+import java.util.List;
+import java.util.Set;
+
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
 
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.execute.ResultCollector;
@@ -42,15 +51,9 @@ import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.NotAuthorizedException;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
+import org.apache.geode.security.ResourcePermission.Target;
+
 
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.text.DecimalFormat;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
 /**
  * Commands for deploying, un-deploying and listing files deployed using the command line shell.
@@ -76,6 +79,7 @@ public class DeployCommands implements GfshCommand {
   @CliMetaData(
       interceptor = "org.apache.geode.management.internal.cli.commands.DeployCommands$Interceptor",
       relatedTopic = {CliStrings.TOPIC_GEODE_CONFIG})
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE, target = Target.JAR)
   public Result deploy(
       @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS}, help = CliStrings.DEPLOY__GROUP__HELP,
           optionContext = ConverterHint.MEMBERGROUP) String[] groups,
@@ -86,11 +90,7 @@ public class DeployCommands implements GfshCommand {
 
       // since deploy function can potentially do a lot of damage to security, this action should
       // require these following privileges
-      SecurityService securityService = getCache().getSecurityService();
-      securityService.authorizeClusterManage();
-      securityService.authorizeClusterWrite();
-      securityService.authorizeDataManage();
-      securityService.authorizeDataWrite();
+      SecurityService securityService = getSecurityService();
 
       TabularResultData tabularData = ResultBuilder.createTabularResultData();
 
@@ -155,13 +155,13 @@ public class DeployCommands implements GfshCommand {
    */
   @CliCommand(value = {CliStrings.UNDEPLOY}, help = CliStrings.UNDEPLOY__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_CONFIG})
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE, target = Target.JAR)
   public Result undeploy(
       @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
           help = CliStrings.UNDEPLOY__GROUP__HELP,
           optionContext = ConverterHint.MEMBERGROUP) String[] groups,
-      @CliOption(key = {CliStrings.JAR, CliStrings.JARS}, help = CliStrings.UNDEPLOY__JAR__HELP,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE) String[] jars) {
+      @CliOption(key = {CliStrings.JAR, CliStrings.JARS},
+          help = CliStrings.UNDEPLOY__JAR__HELP) String[] jars) {
 
     try {
       TabularResultData tabularData = ResultBuilder.createTabularResultData();
@@ -289,7 +289,7 @@ public class DeployCommands implements GfshCommand {
     public Result preExecution(GfshParseResult parseResult) {
       // 2nd argument is the jar
       String[] jars = (String[]) parseResult.getArguments()[1];
-      // 3rd arguemnt is the dir
+      // 3rd argument is the dir
       String dir = (String) parseResult.getArguments()[2];
 
       if (ArrayUtils.isEmpty(jars) && StringUtils.isBlank(dir)) {

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommands.java
index e14c3a6..80f3804 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommands.java
@@ -14,6 +14,28 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.GemFireIOException;
 import org.apache.geode.SystemFailure;
 import org.apache.geode.admin.BackupStatus;
@@ -68,32 +90,9 @@ import org.apache.geode.management.internal.cli.util.MemberNotFoundException;
 import org.apache.geode.management.internal.configuration.domain.XmlEntity;
 import org.apache.geode.management.internal.messages.CompactRequest;
 import org.apache.geode.management.internal.security.ResourceOperation;
-import org.apache.geode.security.ResourcePermission.Target;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicReference;
+import org.apache.geode.security.ResourcePermission.Target;
 
 /**
  * The DiskStoreCommands class encapsulates all GemFire Disk Store commands in Gfsh.
@@ -103,27 +102,31 @@ import java.util.concurrent.atomic.AtomicReference;
  */
 @SuppressWarnings("unused")
 public class DiskStoreCommands implements GfshCommand {
+
   protected Set<DistributedMember> getNormalMembers(final InternalCache cache) {
     // TODO determine what this does (as it is untested and unmockable!)
     return CliUtil.getAllNormalMembers(cache);
   }
 
+  /**
+   * Internally, we also verify the resource operation permissions CLUSTER:WRITE:DISK if the region
+   * is persistent
+   */
   @CliCommand(value = CliStrings.BACKUP_DISK_STORE, help = CliStrings.BACKUP_DISK_STORE__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
   @ResourceOperation(resource = Resource.DATA, operation = Operation.READ)
   public Result backupDiskStore(
-
       @CliOption(key = CliStrings.BACKUP_DISK_STORE__DISKDIRS,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.BACKUP_DISK_STORE__DISKDIRS__HELP, mandatory = true) String targetDir,
       @CliOption(key = CliStrings.BACKUP_DISK_STORE__BASELINEDIR,
           help = CliStrings.BACKUP_DISK_STORE__BASELINEDIR__HELP) String baselineDir) {
 
-    Result result = null;
+    getSecurityService().authorize(Resource.CLUSTER, Operation.WRITE, Target.DISK);
+    Result result;
     try {
       InternalCache cache = getCache();
       DM dm = cache.getDistributionManager();
-      BackupStatus backupStatus = null;
+      BackupStatus backupStatus;
 
       if (baselineDir != null && !baselineDir.isEmpty()) {
         backupStatus = AdminDistributedSystemImpl.backupAllMembers(dm, new File(targetDir),
@@ -159,11 +162,11 @@ public class DiskStoreCommands implements GfshCommand {
               String directory = persistentId.getDirectory();
 
               if (printMember) {
-                writeToBackupDisktoreTable(backedupDiskStoresTable, memberName, UUID, hostName,
+                writeToBackupDiskStoreTable(backedupDiskStoresTable, memberName, UUID, hostName,
                     directory);
                 printMember = false;
               } else {
-                writeToBackupDisktoreTable(backedupDiskStoresTable, "", UUID, hostName, directory);
+                writeToBackupDiskStoreTable(backedupDiskStoresTable, "", UUID, hostName, directory);
               }
             }
           }
@@ -197,8 +200,8 @@ public class DiskStoreCommands implements GfshCommand {
     return result;
   }
 
-  private void writeToBackupDisktoreTable(TabularResultData backedupDiskStoreTable, String memberId,
-      String UUID, String host, String directory) {
+  private void writeToBackupDiskStoreTable(TabularResultData backedupDiskStoreTable,
+      String memberId, String UUID, String host, String directory) {
     backedupDiskStoreTable.accumulate(CliStrings.BACKUP_DISK_STORE_MSG_MEMBER, memberId);
     backedupDiskStoreTable.accumulate(CliStrings.BACKUP_DISK_STORE_MSG_UUID, UUID);
     backedupDiskStoreTable.accumulate(CliStrings.BACKUP_DISK_STORE_MSG_DIRECTORY, directory);
@@ -206,7 +209,7 @@ public class DiskStoreCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.LIST_DISK_STORE, help = CliStrings.LIST_DISK_STORE__HELP)
-  @CliMetaData(shellOnly = false, relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   public Result listDiskStore() {
     try {
@@ -242,7 +245,7 @@ public class DiskStoreCommands implements GfshCommand {
 
     final List<?> results = (List<?>) resultCollector.getResult();
     final List<DiskStoreDetails> distributedSystemMemberDiskStores =
-        new ArrayList<DiskStoreDetails>(results.size());
+        new ArrayList<>(results.size());
 
     for (final Object result : results) {
       if (result instanceof Set) { // ignore FunctionInvocationTargetExceptions and other
@@ -276,8 +279,9 @@ public class DiskStoreCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.CREATE_DISK_STORE, help = CliStrings.CREATE_DISK_STORE__HELP)
-  @CliMetaData(shellOnly = false, relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.DISK)
   public Result createDiskStore(
       @CliOption(key = CliStrings.CREATE_DISK_STORE__NAME, mandatory = true,
           optionContext = ConverterHint.DISKSTORE,
@@ -398,7 +402,7 @@ public class DiskStoreCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.COMPACT_DISK_STORE, help = CliStrings.COMPACT_DISK_STORE__HELP)
-  @CliMetaData(shellOnly = false, relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
       target = Target.DISK)
   public Result compactDiskStore(
@@ -406,9 +410,8 @@ public class DiskStoreCommands implements GfshCommand {
           optionContext = ConverterHint.DISKSTORE,
           help = CliStrings.COMPACT_DISK_STORE__NAME__HELP) String diskStoreName,
       @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.COMPACT_DISK_STORE__GROUP__HELP) String[] groups) {
-    Result result = null;
+    Result result;
 
     try {
       // disk store exists validation
@@ -419,29 +422,24 @@ public class DiskStoreCommands implements GfshCommand {
       } else {
         InternalDistributedSystem ds = getCache().getInternalDistributedSystem();
 
-        Map<DistributedMember, PersistentID> overallCompactInfo =
-            new HashMap<DistributedMember, PersistentID>();
+        Map<DistributedMember, PersistentID> overallCompactInfo = new HashMap<>();
 
         Set<?> otherMembers = ds.getDistributionManager().getOtherNormalDistributionManagerIds();
-        Set<InternalDistributedMember> allMembers = new HashSet<InternalDistributedMember>();
+        Set<InternalDistributedMember> allMembers = new HashSet<>();
 
         for (Object member : otherMembers) {
           allMembers.add((InternalDistributedMember) member);
         }
         allMembers.add(ds.getDistributedMember());
-        otherMembers = null;
 
         String groupInfo = "";
         // if groups are specified, find members in the specified group
         if (groups != null && groups.length > 0) {
           groupInfo = CliStrings.format(CliStrings.COMPACT_DISK_STORE__MSG__FOR_GROUP,
               new Object[] {Arrays.toString(groups) + "."});
-          final Set<InternalDistributedMember> selectedMembers =
-              new HashSet<InternalDistributedMember>();
+          final Set<InternalDistributedMember> selectedMembers = new HashSet<>();
           List<String> targetedGroups = Arrays.asList(groups);
-          for (Iterator<InternalDistributedMember> iterator = allMembers.iterator(); iterator
-              .hasNext();) {
-            InternalDistributedMember member = iterator.next();
+          for (InternalDistributedMember member : allMembers) {
             List<String> memberGroups = member.getGroups();
             if (!Collections.disjoint(targetedGroups, memberGroups)) {
               selectedMembers.add(member);
@@ -486,7 +484,7 @@ public class DiskStoreCommands implements GfshCommand {
           // If compaction happened at all, then prepare the summary
           if (overallCompactInfo != null && !overallCompactInfo.isEmpty()) {
             CompositeResultData compositeResultData = ResultBuilder.createCompositeResultData();
-            SectionResultData section = null;
+            SectionResultData section;
 
             Set<Entry<DistributedMember, PersistentID>> entries = overallCompactInfo.entrySet();
 
@@ -546,20 +544,18 @@ public class DiskStoreCommands implements GfshCommand {
       @CliOption(key = CliStrings.COMPACT_OFFLINE_DISK_STORE__NAME, mandatory = true,
           help = CliStrings.COMPACT_OFFLINE_DISK_STORE__NAME__HELP) String diskStoreName,
       @CliOption(key = CliStrings.COMPACT_OFFLINE_DISK_STORE__DISKDIRS, mandatory = true,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.COMPACT_OFFLINE_DISK_STORE__DISKDIRS__HELP) String[] diskDirs,
       @CliOption(key = CliStrings.COMPACT_OFFLINE_DISK_STORE__MAXOPLOGSIZE,
           unspecifiedDefaultValue = "-1",
           help = CliStrings.COMPACT_OFFLINE_DISK_STORE__MAXOPLOGSIZE__HELP) long maxOplogSize,
       @CliOption(key = CliStrings.COMPACT_OFFLINE_DISK_STORE__J,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.COMPACT_OFFLINE_DISK_STORE__J__HELP) String[] jvmProps) {
-    Result result = null;
+    Result result;
     LogWrapper logWrapper = LogWrapper.getInstance();
 
     StringBuilder output = new StringBuilder();
     StringBuilder error = new StringBuilder();
-    String errorMessage = "";
+    StringBuilder errorMessage = new StringBuilder();
     Process compacterProcess = null;
 
     try {
@@ -570,16 +566,14 @@ public class DiskStoreCommands implements GfshCommand {
                 + validatedDirectories + "\"");
       }
 
-      List<String> commandList = new ArrayList<String>();
+      List<String> commandList = new ArrayList<>();
       commandList.add(System.getProperty("java.home") + File.separatorChar + "bin"
           + File.separatorChar + "java");
 
       configureLogging(commandList);
 
       if (jvmProps != null && jvmProps.length != 0) {
-        for (int i = 0; i < jvmProps.length; i++) {
-          commandList.add(jvmProps[i]);
-        }
+        commandList.addAll(Arrays.asList(jvmProps));
       }
       commandList.add("-classpath");
       commandList.add(System.getProperty("java.class.path", "."));
@@ -612,12 +606,11 @@ public class DiskStoreCommands implements GfshCommand {
       BufferedReader inputReader = new BufferedReader(new InputStreamReader(inputStream));
       BufferedReader errorReader = new BufferedReader(new InputStreamReader(errorStream));
 
-      String line = null;
+      String line;
       while ((line = inputReader.readLine()) != null) {
         output.append(line).append(GfshParser.LINE_SEPARATOR);
       }
 
-      line = null;
       boolean switchToStackTrace = false;
       while ((line = errorReader.readLine()) != null) {
         if (!switchToStackTrace && DiskStoreCompacter.STACKTRACE_START.equals(line)) {
@@ -625,12 +618,12 @@ public class DiskStoreCommands implements GfshCommand {
         } else if (switchToStackTrace) {
           error.append(line).append(GfshParser.LINE_SEPARATOR);
         } else {
-          errorMessage = errorMessage + line;
+          errorMessage.append(line);
         }
       }
 
-      if (!errorMessage.isEmpty()) {
-        throw new GemFireIOException(errorMessage);
+      if (errorMessage.length() > 0) {
+        throw new GemFireIOException(errorMessage.toString());
       }
 
       // do we have to waitFor??
@@ -654,7 +647,7 @@ public class DiskStoreCommands implements GfshCommand {
       if (output.length() != 0) {
         Gfsh.println(output.toString());
       }
-      result = ResultBuilder.createUserErrorResult(errorMessage);
+      result = ResultBuilder.createUserErrorResult(errorMessage.toString());
       if (logWrapper.fineEnabled()) {
         logWrapper.fine(error.toString());
       }
@@ -686,22 +679,20 @@ public class DiskStoreCommands implements GfshCommand {
       @CliOption(key = CliStrings.UPGRADE_OFFLINE_DISK_STORE__NAME, mandatory = true,
           help = CliStrings.UPGRADE_OFFLINE_DISK_STORE__NAME__HELP) String diskStoreName,
       @CliOption(key = CliStrings.UPGRADE_OFFLINE_DISK_STORE__DISKDIRS, mandatory = true,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.UPGRADE_OFFLINE_DISK_STORE__DISKDIRS__HELP) String[] diskDirs,
       @CliOption(key = CliStrings.UPGRADE_OFFLINE_DISK_STORE__MAXOPLOGSIZE,
           unspecifiedDefaultValue = "-1",
           help = CliStrings.UPGRADE_OFFLINE_DISK_STORE__MAXOPLOGSIZE__HELP) long maxOplogSize,
       @CliOption(key = CliStrings.UPGRADE_OFFLINE_DISK_STORE__J,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.UPGRADE_OFFLINE_DISK_STORE__J__HELP) String[] jvmProps)
       throws InterruptedException {
 
-    Result result = null;
+    Result result;
     LogWrapper logWrapper = LogWrapper.getInstance();
 
     StringBuilder output = new StringBuilder();
     StringBuilder error = new StringBuilder();
-    String errorMessage = "";
+    StringBuilder errorMessage = new StringBuilder();
     Process upgraderProcess = null;
 
     try {
@@ -712,16 +703,14 @@ public class DiskStoreCommands implements GfshCommand {
                 + validatedDirectories + "\"");
       }
 
-      List<String> commandList = new ArrayList<String>();
+      List<String> commandList = new ArrayList<>();
       commandList.add(System.getProperty("java.home") + File.separatorChar + "bin"
           + File.separatorChar + "java");
 
       configureLogging(commandList);
 
       if (jvmProps != null && jvmProps.length != 0) {
-        for (int i = 0; i < jvmProps.length; i++) {
-          commandList.add(jvmProps[i]);
-        }
+        commandList.addAll(Arrays.asList(jvmProps));
       }
       commandList.add("-classpath");
       commandList.add(System.getProperty("java.class.path", "."));
@@ -755,12 +744,11 @@ public class DiskStoreCommands implements GfshCommand {
       BufferedReader inputReader = new BufferedReader(new InputStreamReader(inputStream));
       BufferedReader errorReader = new BufferedReader(new InputStreamReader(errorStream));
 
-      String line = null;
+      String line;
       while ((line = inputReader.readLine()) != null) {
         output.append(line).append(GfshParser.LINE_SEPARATOR);
       }
 
-      line = null;
       boolean switchToStackTrace = false;
       while ((line = errorReader.readLine()) != null) {
         if (!switchToStackTrace && DiskStoreUpgrader.STACKTRACE_START.equals(line)) {
@@ -768,12 +756,12 @@ public class DiskStoreCommands implements GfshCommand {
         } else if (switchToStackTrace) {
           error.append(line).append(GfshParser.LINE_SEPARATOR);
         } else {
-          errorMessage = errorMessage + line;
+          errorMessage.append(line);
         }
       }
 
-      if (!errorMessage.isEmpty()) {
-        throw new GemFireIOException(errorMessage);
+      if (errorMessage.length() > 0) {
+        throw new GemFireIOException(errorMessage.toString());
       }
 
       upgraderProcess.destroy();
@@ -796,7 +784,7 @@ public class DiskStoreCommands implements GfshCommand {
       if (output.length() != 0) {
         Gfsh.println(output.toString());
       }
-      result = ResultBuilder.createUserErrorResult(errorMessage);
+      result = ResultBuilder.createUserErrorResult(errorMessage.toString());
       if (logWrapper.fineEnabled()) {
         logWrapper.fine(error.toString());
       }
@@ -823,7 +811,7 @@ public class DiskStoreCommands implements GfshCommand {
   private String validatedDirectories(String[] diskDirs) {
     String invalidDirectories = null;
     StringBuilder builder = null;
-    File diskDir = null;
+    File diskDir;
     for (String diskDirPath : diskDirs) {
       diskDir = new File(diskDirPath);
       if (!diskDir.exists()) {
@@ -843,7 +831,7 @@ public class DiskStoreCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.DESCRIBE_DISK_STORE, help = CliStrings.DESCRIBE_DISK_STORE__HELP)
-  @CliMetaData(shellOnly = false, relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   public Result describeDiskStore(
       @CliOption(key = CliStrings.MEMBER, mandatory = true,
@@ -854,9 +842,7 @@ public class DiskStoreCommands implements GfshCommand {
           help = CliStrings.DESCRIBE_DISK_STORE__NAME__HELP) final String diskStoreName) {
     try {
       return toCompositeResult(getDiskStoreDescription(memberName, diskStoreName));
-    } catch (DiskStoreNotFoundException e) {
-      return ResultBuilder.createShellClientErrorResult(e.getMessage());
-    } catch (MemberNotFoundException e) {
+    } catch (DiskStoreNotFoundException | MemberNotFoundException e) {
       return ResultBuilder.createShellClientErrorResult(e.getMessage());
     } catch (FunctionInvocationTargetException ignore) {
       return ResultBuilder.createGemFireErrorResult(CliStrings
@@ -982,7 +968,8 @@ public class DiskStoreCommands implements GfshCommand {
   @CliCommand(value = CliStrings.REVOKE_MISSING_DISK_STORE,
       help = CliStrings.REVOKE_MISSING_DISK_STORE__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.DISK)
   public Result revokeMissingDiskStore(@CliOption(key = CliStrings.REVOKE_MISSING_DISK_STORE__ID,
       mandatory = true, help = CliStrings.REVOKE_MISSING_DISK_STORE__ID__HELP) String id) {
 
@@ -1049,7 +1036,7 @@ public class DiskStoreCommands implements GfshCommand {
         membersFunctionExecutor.execute(new ShowMissingDiskStoresFunction());
 
     final List<?> results = (List<?>) resultCollector.getResult();
-    final List<Object> distributedPersistentRecoveryDetails = new ArrayList<Object>(results.size());
+    final List<Object> distributedPersistentRecoveryDetails = new ArrayList<>(results.size());
     for (final Object result : results) {
       if (result instanceof Set) { // ignore FunctionInvocationTargetExceptions and other
                                    // Exceptions...
@@ -1062,8 +1049,8 @@ public class DiskStoreCommands implements GfshCommand {
   protected Result toMissingDiskStoresTabularResult(final List<Object> resultDetails)
       throws ResultDataException {
     CompositeResultData crd = ResultBuilder.createCompositeResultData();
-    List<PersistentMemberPattern> missingDiskStores = new ArrayList<PersistentMemberPattern>();
-    List<ColocatedRegionDetails> missingColocatedRegions = new ArrayList<ColocatedRegionDetails>();
+    List<PersistentMemberPattern> missingDiskStores = new ArrayList<>();
+    List<ColocatedRegionDetails> missingColocatedRegions = new ArrayList<>();
 
     for (Object detail : resultDetails) {
       if (detail instanceof PersistentMemberPattern) {
@@ -1082,10 +1069,10 @@ public class DiskStoreCommands implements GfshCommand {
       missingDiskStoresSection.setHeader("Missing Disk Stores");
       TabularResultData missingDiskStoreData = missingDiskStoresSection.addTable();
 
-      for (PersistentMemberPattern peristentMemberDetails : missingDiskStores) {
-        missingDiskStoreData.accumulate("Disk Store ID", peristentMemberDetails.getUUID());
-        missingDiskStoreData.accumulate("Host", peristentMemberDetails.getHost());
-        missingDiskStoreData.accumulate("Directory", peristentMemberDetails.getDirectory());
+      for (PersistentMemberPattern persistentMemberDetails : missingDiskStores) {
+        missingDiskStoreData.accumulate("Disk Store ID", persistentMemberDetails.getUUID());
+        missingDiskStoreData.accumulate("Host", persistentMemberDetails.getHost());
+        missingDiskStoreData.accumulate("Directory", persistentMemberDetails.getDirectory());
       }
     } else {
       SectionResultData noMissingDiskStores = crd.addSection();
@@ -1124,11 +1111,9 @@ public class DiskStoreCommands implements GfshCommand {
       @CliOption(key = CliStrings.DESCRIBE_OFFLINE_DISK_STORE__DISKDIRS, mandatory = true,
           help = CliStrings.DESCRIBE_OFFLINE_DISK_STORE__DISKDIRS__HELP) String[] diskDirs,
       @CliOption(key = CliStrings.DESCRIBE_OFFLINE_DISK_STORE__PDX_TYPES,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.DESCRIBE_OFFLINE_DISK_STORE__PDX_TYPES__HELP) Boolean listPdxTypes,
       @CliOption(key = CliStrings.DESCRIBE_OFFLINE_DISK_STORE__REGIONNAME,
-          help = CliStrings.DESCRIBE_OFFLINE_DISK_STORE__REGIONNAME__HELP,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE) String regionName) {
+          help = CliStrings.DESCRIBE_OFFLINE_DISK_STORE__REGIONNAME__HELP) String regionName) {
 
     try {
       final File[] dirs = new File[diskDirs.length];
@@ -1184,7 +1169,7 @@ public class DiskStoreCommands implements GfshCommand {
       DiskStoreImpl.exportOfflineSnapshot(diskStoreName, dirs, output);
       String resultString =
           CliStrings.format(CliStrings.EXPORT_OFFLINE_DISK_STORE__SUCCESS, diskStoreName, dir);
-      return ResultBuilder.createInfoResult(resultString.toString());
+      return ResultBuilder.createInfoResult(resultString);
     } catch (VirtualMachineError e) {
       SystemFailure.initiateFailure(e);
       throw e;
@@ -1209,31 +1194,25 @@ public class DiskStoreCommands implements GfshCommand {
       @CliOption(key = CliStrings.VALIDATE_DISK_STORE__NAME, mandatory = true,
           help = CliStrings.VALIDATE_DISK_STORE__NAME__HELP) String diskStoreName,
       @CliOption(key = CliStrings.VALIDATE_DISK_STORE__DISKDIRS, mandatory = true,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.VALIDATE_DISK_STORE__DISKDIRS__HELP) String[] diskDirs,
       @CliOption(key = CliStrings.VALIDATE_DISK_STORE__J,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.VALIDATE_DISK_STORE__J__HELP) String[] jvmProps) {
     try {
-      String resultString = new String();
-
       // create a new process ...bug 46075
       StringBuilder dirList = new StringBuilder();
-      for (int i = 0; i < diskDirs.length; i++) {
-        dirList.append(diskDirs[i]);
+      for (String diskDir : diskDirs) {
+        dirList.append(diskDir);
         dirList.append(";");
       }
 
-      List<String> commandList = new ArrayList<String>();
+      List<String> commandList = new ArrayList<>();
       commandList.add(System.getProperty("java.home") + File.separatorChar + "bin"
           + File.separatorChar + "java");
 
       configureLogging(commandList);
 
       if (jvmProps != null && jvmProps.length != 0) {
-        for (int i = 0; i < jvmProps.length; i++) {
-          commandList.add(jvmProps[i]);
-        }
+        commandList.addAll(Arrays.asList(jvmProps));
       }
 
       // Pass any java options on to the command
@@ -1249,23 +1228,22 @@ public class DiskStoreCommands implements GfshCommand {
 
       ProcessBuilder procBuilder = new ProcessBuilder(commandList);
       StringBuilder output = new StringBuilder();
-      String errorString = new String();
+      String errorString = "";
 
       Process validateDiskStoreProcess = procBuilder.redirectErrorStream(true).start();
       InputStream inputStream = validateDiskStoreProcess.getInputStream();
       BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
-      String line = null;
+      String line;
 
       while ((line = br.readLine()) != null) {
         output.append(line).append(GfshParser.LINE_SEPARATOR);
       }
       validateDiskStoreProcess.destroy();
 
-      if (errorString != null) {
-        output.append(errorString).append(GfshParser.LINE_SEPARATOR);
-      }
-      resultString = "Validating " + diskStoreName + GfshParser.LINE_SEPARATOR + output.toString();
-      return ResultBuilder.createInfoResult(resultString.toString());
+      output.append(errorString).append(GfshParser.LINE_SEPARATOR);
+      String resultString =
+          "Validating " + diskStoreName + GfshParser.LINE_SEPARATOR + output.toString();
+      return ResultBuilder.createInfoResult(resultString);
     } catch (IOException ex) {
       return ResultBuilder.createGemFireErrorResult(CliStrings
           .format(CliStrings.VALIDATE_DISK_STORE__MSG__IO_ERROR, diskStoreName, ex.getMessage()));
@@ -1285,39 +1263,30 @@ public class DiskStoreCommands implements GfshCommand {
       @CliOption(key = CliStrings.ALTER_DISK_STORE__REGIONNAME, mandatory = true,
           help = CliStrings.ALTER_DISK_STORE__REGIONNAME__HELP) String regionName,
       @CliOption(key = CliStrings.ALTER_DISK_STORE__DISKDIRS,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.ALTER_DISK_STORE__DISKDIRS__HELP, mandatory = true) String[] diskDirs,
-      @CliOption(key = CliStrings.ALTER_DISK_STORE__COMPRESSOR,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
-          specifiedDefaultValue = "none",
+      @CliOption(key = CliStrings.ALTER_DISK_STORE__COMPRESSOR, specifiedDefaultValue = "none",
           help = CliStrings.ALTER_DISK_STORE__COMPRESSOR__HELP) String compressorClassName,
       @CliOption(key = CliStrings.ALTER_DISK_STORE__CONCURRENCY__LEVEL,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.ALTER_DISK_STORE__CONCURRENCY__LEVEL__HELP) Integer concurrencyLevel,
       @CliOption(key = CliStrings.ALTER_DISK_STORE__STATISTICS__ENABLED,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.ALTER_DISK_STORE__STATISTICS__ENABLED__HELP) Boolean statisticsEnabled,
       @CliOption(key = CliStrings.ALTER_DISK_STORE__INITIAL__CAPACITY,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.ALTER_DISK_STORE__INITIAL__CAPACITY__HELP) Integer initialCapacity,
       @CliOption(key = CliStrings.ALTER_DISK_STORE__LOAD__FACTOR,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.ALTER_DISK_STORE__LOAD__FACTOR__HELP) Float loadFactor,
       @CliOption(key = CliStrings.ALTER_DISK_STORE__LRU__EVICTION__ACTION,
           help = CliStrings.ALTER_DISK_STORE__LRU__EVICTION__ACTION__HELP) String lruEvictionAction,
       @CliOption(key = CliStrings.ALTER_DISK_STORE__LRU__EVICTION__ALGORITHM,
           help = CliStrings.ALTER_DISK_STORE__LRU__EVICTION__ALGORITHM__HELP) String lruEvictionAlgo,
       @CliOption(key = CliStrings.ALTER_DISK_STORE__LRU__EVICTION__LIMIT,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.ALTER_DISK_STORE__LRU__EVICTION__LIMIT__HELP) Integer lruEvictionLimit,
       @CliOption(key = CliStrings.ALTER_DISK_STORE__OFF_HEAP,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.ALTER_DISK_STORE__OFF_HEAP__HELP) Boolean offHeap,
       @CliOption(key = CliStrings.ALTER_DISK_STORE__REMOVE,
-          help = CliStrings.ALTER_DISK_STORE__REMOVE__HELP, mandatory = false,
-          specifiedDefaultValue = "true", unspecifiedDefaultValue = "false") boolean remove) {
+          help = CliStrings.ALTER_DISK_STORE__REMOVE__HELP, specifiedDefaultValue = "true",
+          unspecifiedDefaultValue = "false") boolean remove) {
 
-    Result result = null;
+    Result result;
 
     try {
       File[] dirs = null;
@@ -1390,8 +1359,9 @@ public class DiskStoreCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.DESTROY_DISK_STORE, help = CliStrings.DESTROY_DISK_STORE__HELP)
-  @CliMetaData(shellOnly = false, relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.DISK)
   public Result destroyDiskStore(
       @CliOption(key = CliStrings.DESTROY_DISK_STORE__NAME, mandatory = true,
           help = CliStrings.DESTROY_DISK_STORE__NAME__HELP) String name,

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DurableClientCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DurableClientCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DurableClientCommands.java
index 87ad1be..c5d859e 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DurableClientCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DurableClientCommands.java
@@ -14,6 +14,16 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.management.cli.CliMetaData;
@@ -28,7 +38,6 @@ import org.apache.geode.management.internal.cli.functions.CloseDurableCqFunction
 import org.apache.geode.management.internal.cli.functions.GetSubscriptionQueueSizeFunction;
 import org.apache.geode.management.internal.cli.functions.ListDurableCqNamesFunction;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.result.CommandResultException;
 import org.apache.geode.management.internal.cli.result.ErrorResultData;
 import org.apache.geode.management.internal.cli.result.InfoResultData;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
@@ -36,15 +45,7 @@ import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
+import org.apache.geode.security.ResourcePermission.Target;
 
 /**
  * The DurableClientCommands class encapsulates all GemFire shell (Gfsh) commands related to durable
@@ -63,7 +64,7 @@ public class DurableClientCommands implements GfshCommand {
       new GetSubscriptionQueueSizeFunction();
 
   @CliCommand(value = CliStrings.LIST_DURABLE_CQS, help = CliStrings.LIST_DURABLE_CQS__HELP)
-  @CliMetaData(shellOnly = false)
+  @CliMetaData()
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   public Result listDurableClientCqs(
       @CliOption(key = CliStrings.LIST_DURABLE_CQS__DURABLECLIENTID, mandatory = true,
@@ -76,7 +77,7 @@ public class DurableClientCommands implements GfshCommand {
       @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
           help = CliStrings.LIST_DURABLE_CQS__GROUP__HELP,
           optionContext = ConverterHint.MEMBERGROUP) final String[] group) {
-    Result result = null;
+    Result result;
     try {
 
       boolean noResults = true;
@@ -89,9 +90,9 @@ public class DurableClientCommands implements GfshCommand {
       final ResultCollector<?, ?> rc =
           CliUtil.executeFunction(new ListDurableCqNamesFunction(), durableClientId, targetMembers);
       final List<DurableCqNamesResult> results = (List<DurableCqNamesResult>) rc.getResult();
-      Map<String, List<String>> memberCqNamesMap = new TreeMap<String, List<String>>();
-      Map<String, List<String>> errorMessageNodes = new HashMap<String, List<String>>();
-      Map<String, List<String>> exceptionMessageNodes = new HashMap<String, List<String>>();
+      Map<String, List<String>> memberCqNamesMap = new TreeMap<>();
+      Map<String, List<String>> errorMessageNodes = new HashMap<>();
+      Map<String, List<String>> exceptionMessageNodes = new HashMap<>();
 
       for (DurableCqNamesResult memberResult : results) {
         if (memberResult != null) {
@@ -142,21 +143,21 @@ public class DurableClientCommands implements GfshCommand {
 
   @CliCommand(value = CliStrings.COUNT_DURABLE_CQ_EVENTS,
       help = CliStrings.COUNT_DURABLE_CQ_EVENTS__HELP)
-  @CliMetaData(shellOnly = false)
+  @CliMetaData()
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   public Result countDurableCqEvents(
       @CliOption(key = CliStrings.COUNT_DURABLE_CQ_EVENTS__DURABLE__CLIENT__ID, mandatory = true,
           help = CliStrings.COUNT_DURABLE_CQ_EVENTS__DURABLE__CLIENT__ID__HELP) final String durableClientId,
-      @CliOption(key = CliStrings.COUNT_DURABLE_CQ_EVENTS__DURABLE__CQ__NAME, mandatory = false,
+      @CliOption(key = CliStrings.COUNT_DURABLE_CQ_EVENTS__DURABLE__CQ__NAME,
           help = CliStrings.COUNT_DURABLE_CQ_EVENTS__DURABLE__CQ__NAME__HELP) final String cqName,
-      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS}, mandatory = false,
+      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
           help = CliStrings.COUNT_DURABLE_CQ_EVENTS__MEMBER__HELP,
           optionContext = ConverterHint.MEMBERIDNAME) final String[] memberNameOrId,
-      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS}, mandatory = false,
+      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
           help = CliStrings.COUNT_DURABLE_CQ_EVENTS__GROUP__HELP,
           optionContext = ConverterHint.MEMBERGROUP) final String[] group) {
 
-    Result result = null;
+    Result result;
     try {
       Set<DistributedMember> targetMembers = CliUtil.findMembers(group, memberNameOrId);
 
@@ -191,19 +192,20 @@ public class DurableClientCommands implements GfshCommand {
 
   @CliCommand(value = CliStrings.CLOSE_DURABLE_CLIENTS,
       help = CliStrings.CLOSE_DURABLE_CLIENTS__HELP)
-  @CliMetaData(shellOnly = false)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @CliMetaData()
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
   public Result closeDurableClient(
       @CliOption(key = CliStrings.CLOSE_DURABLE_CLIENTS__CLIENT__ID, mandatory = true,
           help = CliStrings.CLOSE_DURABLE_CLIENTS__CLIENT__ID__HELP) final String durableClientId,
-      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS}, mandatory = false,
+      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
           help = CliStrings.CLOSE_DURABLE_CLIENTS__MEMBER__HELP,
           optionContext = ConverterHint.MEMBERIDNAME) final String[] memberNameOrId,
-      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS}, mandatory = false,
+      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
           help = CliStrings.COUNT_DURABLE_CQ_EVENTS__GROUP__HELP,
           optionContext = ConverterHint.MEMBERGROUP) final String[] group) {
 
-    Result result = null;
+    Result result;
     try {
 
       Set<DistributedMember> targetMembers = CliUtil.findMembers(group, memberNameOrId);
@@ -228,8 +230,9 @@ public class DurableClientCommands implements GfshCommand {
 
 
   @CliCommand(value = CliStrings.CLOSE_DURABLE_CQS, help = CliStrings.CLOSE_DURABLE_CQS__HELP)
-  @CliMetaData(shellOnly = false)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @CliMetaData()
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
   public Result closeDurableCqs(@CliOption(key = CliStrings.CLOSE_DURABLE_CQS__DURABLE__CLIENT__ID,
       mandatory = true,
       help = CliStrings.CLOSE_DURABLE_CQS__DURABLE__CLIENT__ID__HELP) final String durableClientId,
@@ -237,14 +240,14 @@ public class DurableClientCommands implements GfshCommand {
       @CliOption(key = CliStrings.CLOSE_DURABLE_CQS__NAME, mandatory = true,
           help = CliStrings.CLOSE_DURABLE_CQS__NAME__HELP) final String cqName,
 
-      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS}, mandatory = false,
+      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
           help = CliStrings.CLOSE_DURABLE_CQS__MEMBER__HELP,
           optionContext = ConverterHint.MEMBERIDNAME) final String[] memberNameOrId,
 
-      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS}, mandatory = false,
+      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
           help = CliStrings.CLOSE_DURABLE_CQS__GROUP__HELP,
           optionContext = ConverterHint.MEMBERGROUP) final String[] group) {
-    Result result = null;
+    Result result;
     try {
       Set<DistributedMember> targetMembers = CliUtil.findMembers(group, memberNameOrId);
 
@@ -273,14 +276,14 @@ public class DurableClientCommands implements GfshCommand {
 
   private Result buildResult(List<MemberResult> results, String successHeader,
       String failureHeader) {
-    Result result = null;
+    Result result;
     boolean failure = true;
     boolean partialFailure = false;
-    Map<String, List<String>> errorMap = new HashMap<String, List<String>>();
-    Map<String, List<String>> successMap = new HashMap<String, List<String>>();
-    Map<String, List<String>> exceptionMap = new HashMap<String, List<String>>();
+    Map<String, List<String>> errorMap = new HashMap<>();
+    Map<String, List<String>> successMap = new HashMap<>();
+    Map<String, List<String>> exceptionMap = new HashMap<>();
 
-    /***
+    /*
      * Aggregate the results from the members
      */
     for (MemberResult memberResult : results) {
@@ -314,20 +317,19 @@ public class DurableClientCommands implements GfshCommand {
 
   private Result buildTableResultForQueueSize(List<SubscriptionQueueSizeResult> results,
       String queueSizeColumnName) {
-    Result result = null;
+    Result result;
     boolean failure = true;
 
-    Map<String, List<String>> failureMap = new HashMap<String, List<String>>();
-    Map<String, Long> memberQueueSizeTable = new TreeMap<String, Long>();
+    Map<String, List<String>> failureMap = new HashMap<>();
+    Map<String, Long> memberQueueSizeTable = new TreeMap<>();
 
-    /***
+    /*
      * Aggregate the results from the members
      */
     for (SubscriptionQueueSizeResult memberResult : results) {
 
       if (memberResult.isSuccessful()) {
         failure = false;
-        memberResult.getSubscriptionQueueSize();
         memberQueueSizeTable.put(memberResult.getMemberNameOrId(),
             memberResult.getSubscriptionQueueSize());
       } else {
@@ -361,7 +363,7 @@ public class DurableClientCommands implements GfshCommand {
     List<String> members = map.get(message);
 
     if (members == null) {
-      members = new LinkedList<String>();
+      members = new LinkedList<>();
     }
     members.add(memberNameOrId);
     map.put(message, members);
@@ -373,11 +375,11 @@ public class DurableClientCommands implements GfshCommand {
     Set<String> successMessages = successMap.keySet();
 
     for (String successMessage : successMessages) {
-      ird.addLine(CliStrings.format(CliStrings.ACTION_SUCCCEEDED_ON_MEMBER, successMessage));
+      ird.addLine(CliStrings.format(CliStrings.ACTION_SUCCEEDED_ON_MEMBER, successMessage));
 
-      List<String> successfullMembers = successMap.get(successMessage);
+      List<String> successfulMembers = successMap.get(successMessage);
       int num = 0;
-      for (String member : successfullMembers) {
+      for (String member : successfulMembers) {
         ird.addLine("" + ++num + "." + member);
       }
       ird.addLine("\n");


[15/46] geode git commit: (no ticket) docs code cleanup - gfsh start command reference

Posted by zh...@apache.org.
(no ticket) docs code cleanup - gfsh start command reference


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

Branch: refs/heads/feature/GEM-1483
Commit: 7df5af35ac885c007e2287316213360a12241c21
Parents: ee5f60c
Author: Dave Barnes <db...@pivotal.io>
Authored: Tue Jun 20 13:08:33 2017 -0700
Committer: Dave Barnes <db...@pivotal.io>
Committed: Tue Jun 20 13:08:33 2017 -0700

----------------------------------------------------------------------
 .../gfsh/command-pages/start.html.md.erb        | 21 +++++---------------
 1 file changed, 5 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/7df5af35/geode-docs/tools_modules/gfsh/command-pages/start.html.md.erb
----------------------------------------------------------------------
diff --git a/geode-docs/tools_modules/gfsh/command-pages/start.html.md.erb b/geode-docs/tools_modules/gfsh/command-pages/start.html.md.erb
index 0bec322..0044b9e 100644
--- a/geode-docs/tools_modules/gfsh/command-pages/start.html.md.erb
+++ b/geode-docs/tools_modules/gfsh/command-pages/start.html.md.erb
@@ -65,8 +65,6 @@ Note that you can only have one gateway receiver on each member, and unlike a ga
 start gateway-receiver [--group=value(,value)*] [--member=value]
 ```
 
-<a id="topic_67738A5B68E84DEE95D1C92DAB2E26E5__table_eyh_3vg_2w"></a>
-
 | Name                                           | Description                                                      |
 |------------------------------------------------|------------------------------------------------------------------|
 | <span class="keyword parmname">\\-\\-member</span> | Name or ID of the member on which to start the Gateway Receiver. |
@@ -117,8 +115,6 @@ For information on how to configure a gateway sender, see [Configure Gateway Sen
 start gateway-sender --id=value [--group=value(,value)*] [--member=value]
 ```
 
-<a id="topic_AB8BA3F42B9645A8BE9BD97CE2F839A8__table_gxc_lvg_2w"></a>
-
 | Name                                           | Description                                               |
 |------------------------------------------------|-----------------------------------------------------------|
 | <span class="keyword parmname">\\-\\-id</span>     | *Required.* ID of the GatewaySender.                      |
@@ -175,8 +171,6 @@ start jconsole [--interval=<seconds>] [--notile] [--version]
 [--J<jconsole JVM options>]
 ```
 
-<a id="topic_D00507416F3944DFAB48D2FA2B9E4A31__table_uck_4vg_2w"></a>
-
 | Name                                               | Description                                                                                                                                                                                                                                                                                                                                                                                                | Default Value |
 |----------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
 | <span class="keyword parmname">\\-\\-interval</span>   | Set the update interval to n seconds (default is 4 seconds). (Equivalent to JConsole's `-interval=n`)                                                                                                                                                                                                                                                                                                      | 4             |
@@ -238,10 +232,8 @@ Start the JDK's Java VisualVM monitoring application in a separate process.
 start jvisualvm [--J=value(,value)*]
 ```
 
-<a id="topic_5B5BF8BEE905463D8B7762B89E2D65E7__table_ssp_svg_2w"></a>
-
-| Name                                      | Description                                                                                                    |
-|-------------------------------------------|----------------------------------------------------------------------------------------------------------------|
+| Name                                      | Description |
+|-------------------------------------------|------------------------------------------------------------------------------------------------|
 | <span class="keyword parmname">\\-\\-J</span> | VM-option passed to the spawned CacheServer VM. For example: `-J-Dfoo.bar=true` for setting foo.bar to 'true'. |
 
 <span class="tablecap">Table 4. Start JVisalVM Parameters</span>
@@ -280,10 +272,7 @@ start locator --name=value [--bind-address=value] [--force(=value)] [--group=val
  [--J=value(,value)*]
 ```
 
-<a id="topic_591260CF25D64562A0EDD7260D2AC6D4__table_hly_vvg_2w"></a>
-
 <table>
-<caption><span class="tablecap">Table 5. Parameters</span></caption>
 <colgroup>
 <col width="33%" />
 <col width="33%" />
@@ -468,8 +457,6 @@ For more information on Geode Pulse, see [Geode Pulse](../../pulse/pulse-overvie
 start pulse [--url=value]
 ```
 
-<a id="topic_E906BA7D9E7F4C5890FEFA7ECD40DD77__table_cv3_w54_k4eee"></a>
-
 | Name                                        | Description                      | Default                       |
 |---------------------------------------------|----------------------------------|-------------------------------|
 | <span class="keyword parmname">\\-\\-url</span> | URL of the Pulse Web application | `http://localhost:7070/pulse` |
@@ -520,7 +507,6 @@ start server --name=value [--assign-buckets(=value)] [--bind-address=value]
 <a id="topic_3764EE2DB18B4AE4A625E0354471738A__table_at5_bwg_2w"></a>
 
 <table>
-<caption><span class="tablecap">Table 7. Parameters</span></caption>
 <colgroup>
 <col width="33%" />
 <col width="33%" />
@@ -795,6 +781,9 @@ the cluster.
 </tbody>
 </table>
 
+<span class="tablecap">Table 7. Start Server Parameters</span>
+
+
 ### <a id="topic_3764EE2DB18B4AE4A625E0354471738A__section_A50120613D3C4A848463236C4EFF18C7" class="no-quick-link"></a>Examples
 
 ``` pre


[09/46] geode git commit: GEODE-3092: fix specifiedDefaultValue for cacheLoader and cacheWriter

Posted by zh...@apache.org.
GEODE-3092: fix specifiedDefaultValue for cacheLoader and cacheWriter


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

Branch: refs/heads/feature/GEM-1483
Commit: c6d88f748f32293edfb2c92e914a12b21969c061
Parents: 87c26be
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Mon Jun 19 09:08:35 2017 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Mon Jun 19 14:02:24 2017 -0700

----------------------------------------------------------------------
 .../CreateAlterDestroyRegionCommands.java       | 45 ++++++++++----------
 .../internal/cli/GfshParserParsingTest.java     | 19 +++++++--
 2 files changed, 38 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/c6d88f74/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
index 842802b..bf22854 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java
@@ -14,7 +14,28 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.regex.Pattern;
+
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
 import org.apache.commons.lang.StringUtils;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.LogWriter;
 import org.apache.geode.cache.DataPolicy;
 import org.apache.geode.cache.ExpirationAttributes;
@@ -58,26 +79,6 @@ import org.apache.geode.management.internal.configuration.domain.XmlEntity;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.regex.Pattern;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
 
 /**
  * @since GemFire 7.0
@@ -408,9 +409,9 @@ public class CreateAlterDestroyRegionCommands implements GfshCommand {
           help = CliStrings.ALTER_REGION__REGIONEXPIRATIONTTLACTION__HELP) String regionExpirationTTLAction,
       @CliOption(key = CliStrings.ALTER_REGION__CACHELISTENER, specifiedDefaultValue = "",
           help = CliStrings.ALTER_REGION__CACHELISTENER__HELP) String[] cacheListeners,
-      @CliOption(key = CliStrings.ALTER_REGION__CACHELOADER, specifiedDefaultValue = "null",
+      @CliOption(key = CliStrings.ALTER_REGION__CACHELOADER, specifiedDefaultValue = "",
           help = CliStrings.ALTER_REGION__CACHELOADER__HELP) String cacheLoader,
-      @CliOption(key = CliStrings.ALTER_REGION__CACHEWRITER, specifiedDefaultValue = "null",
+      @CliOption(key = CliStrings.ALTER_REGION__CACHEWRITER, specifiedDefaultValue = "",
           help = CliStrings.ALTER_REGION__CACHEWRITER__HELP) String cacheWriter,
       @CliOption(key = CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID, specifiedDefaultValue = "",
           help = CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID__HELP) String[] asyncEventQueueIds,

http://git-wip-us.apache.org/repos/asf/geode/blob/c6d88f74/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java
index 47d150d..961cdf8 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java
@@ -17,15 +17,16 @@ package org.apache.geode.management.internal.cli;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.assertEquals;
 
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.test.dunit.rules.GfshParserRule;
-import org.apache.geode.test.junit.categories.IntegrationTest;
+import java.util.Map;
+
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.springframework.shell.event.ParseResult;
 
-import java.util.Map;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.test.dunit.rules.GfshParserRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
 
 @Category(IntegrationTest.class)
 public class GfshParserParsingTest {
@@ -290,4 +291,14 @@ public class GfshParserParsingTest {
     GfshParseResult result = parser.parse(command);
     assertThat(result.getParamValue("name")).isEqualTo("\\u0005Name");
   }
+
+  @Test
+  public void testAlterRegion() throws Exception {
+    String command =
+        "alter region --name=/Person --cache-writer='' --cache-listener='' --cache-loader=''";
+    GfshParseResult result = parser.parse(command);
+    assertThat(result.getParamValue("cache-writer")).isNotNull().isEmpty();
+    assertThat(result.getParamValue("cache-listener")).isNotNull().isEmpty();
+    assertThat(result.getParamValue("cache-loader")).isNotNull().isEmpty();
+  }
 }


[19/46] geode git commit: GEODE-2820: Added awaitlity clause to wait for the index size to be correct

Posted by zh...@apache.org.
GEODE-2820: Added awaitlity clause to wait for the index size to be correct

	* Added awaitility clause to wait for all the indexes to have all the entries
	* This is done to make sure that the queries are executed after the indexes are ready.

	This closes #588


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

Branch: refs/heads/feature/GEM-1483
Commit: 822946b9ddc426b45857c6b3919cd0b8b5a98406
Parents: 43b00bd
Author: nabarun <nn...@pivotal.io>
Authored: Thu Jun 15 16:32:46 2017 -0700
Committer: nabarun <nn...@pivotal.io>
Committed: Wed Jun 21 15:12:49 2017 -0700

----------------------------------------------------------------------
 .../dunit/QueryIndexUsingXMLDUnitTest.java      | 30 +++++++++++++++++---
 1 file changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/822946b9/geode-core/src/test/java/org/apache/geode/cache/query/dunit/QueryIndexUsingXMLDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/query/dunit/QueryIndexUsingXMLDUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/query/dunit/QueryIndexUsingXMLDUnitTest.java
index 83f1da3..e08b019 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/query/dunit/QueryIndexUsingXMLDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/query/dunit/QueryIndexUsingXMLDUnitTest.java
@@ -21,6 +21,7 @@ import static org.apache.geode.test.dunit.Invoke.*;
 import static org.apache.geode.test.dunit.LogWriterUtils.*;
 import static org.assertj.core.api.Assertions.*;
 import static org.awaitility.Awaitility.*;
+import static org.junit.Assert.assertEquals;
 
 import java.io.File;
 import java.net.URL;
@@ -28,8 +29,10 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Properties;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.io.FileUtils;
+import org.awaitility.Awaitility;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -473,11 +476,7 @@ public class QueryIndexUsingXMLDUnitTest extends JUnit4CacheTestCase {
 
   /**
    * Creates async indexes and compares the results between index and non-index results.
-   * <p>
-   * DISABLED. This test is disabled due to a high rate of throw new AssertionError. See ticket
-   * #52167
    */
-  @Ignore("TODO: test is disabled because of #52167")
   @Test
   public void testCreateAsyncIndexWhileDoingGIIAndCompareQueryResults() throws Exception {
     Host host = Host.getHost(0);
@@ -510,11 +509,34 @@ public class QueryIndexUsingXMLDUnitTest extends JUnit4CacheTestCase {
     vm1.invoke(prIndexCreationCheck(PERSISTENT_REG_NAME, "secIndex", 50));
     vm1.invoke(indexCreationCheck(REP_REG_NAME, "secIndex"));
 
+    vm0.invoke(() -> validateIndexSize());
+    vm1.invoke(() -> validateIndexSize());
+
+
     // Execute query and verify index usage
     vm0.invoke(executeQueryAndCompareResult(false));
     vm1.invoke(executeQueryAndCompareResult(false));
   }
 
+  public void validateIndexSize() {
+    Awaitility.await().atMost(60, TimeUnit.SECONDS).until(() -> {
+      boolean indexSizeCheck_NAME = validateIndexSizeForRegion(NAME);
+      boolean indexSizeCheck_REP_REG_NAME = validateIndexSizeForRegion(REP_REG_NAME);
+      boolean indexSizeCheck_PERSISTENT_REG_NAME = validateIndexSizeForRegion(PERSISTENT_REG_NAME);
+      assertEquals("Index does not contain all the entries after 60 seconds have elapsed ", true,
+          (indexSizeCheck_NAME && indexSizeCheck_REP_REG_NAME
+              && indexSizeCheck_PERSISTENT_REG_NAME));
+    });
+  }
+
+  private boolean validateIndexSizeForRegion(final String regionName) {
+    Region region = getCache().getRegion(regionName);
+    QueryService queryService = getCache().getQueryService();
+    return queryService.getIndex(region, "statusIndex").getStatistics().getNumberOfValues() == 500
+        && queryService.getIndex(region, "idIndex").getStatistics().getNumberOfValues() == 500
+        && queryService.getIndex(region, "statusIndex").getStatistics().getNumberOfValues() == 500;
+  }
+
   @Test
   public void testIndexCreationForReplicatedPersistentOverFlowRegionOnRestart() throws Exception {
     Host host = Host.getHost(0);


[10/46] geode git commit: Update geode-book/README.md

Posted by zh...@apache.org.
Update geode-book/README.md


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

Branch: refs/heads/feature/GEM-1483
Commit: 8db7862758cfb79d5097f1fefa4e230186668f22
Parents: c6d88f7
Author: Dave Barnes <db...@pivotal.io>
Authored: Mon Jun 19 14:07:31 2017 -0700
Committer: Dave Barnes <db...@pivotal.io>
Committed: Mon Jun 19 14:07:31 2017 -0700

----------------------------------------------------------------------
 geode-book/README.md | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/8db78627/geode-book/README.md
----------------------------------------------------------------------
diff --git a/geode-book/README.md b/geode-book/README.md
index f381b16..a542ce2 100644
--- a/geode-book/README.md
+++ b/geode-book/README.md
@@ -78,12 +78,22 @@ where `XY` is the product version of your documentation (e.g., `{geode-site}/web
 
 2. Navigate to the User Guide you have built in the Geode repository: `{geode-project-dir}/geode-book/final_app/public/docs/guide/XY`.
 
-3. Use `tar` to copy the directory in order to preserve links and other filesystem niceties. Create the tarfile in your Desktop for easy access on the retrieval side.
-  
-  To copy the directory, enter:
+3. Use `tar` to copy the directory in order to preserve links and other filesystem niceties.
+
+  a. Create the tarfile in your Desktop for easy access on the retrieval side.
 
     ```
     $ tar cvf ~/Desktop/new-guide-content.tar .
+    ```
+  b. Create the destination directory in the `geode-site` repo:
+
+    ```
+    $ mkdir -p {geode-site}/website/content/docs/guide/XY
+    ```
+
+  c. Navigate to the target directory and un-tar the userguide archive:
+
+    ```
     $ cd {geode-site}/website/content/docs/guide/XY
     $ tar xvf ~/Desktop/new-guide-content.tar
     ```


[31/46] geode git commit: GEODE-2819 Document http status code 414 for PUT

Posted by zh...@apache.org.
GEODE-2819 Document http status code 414 for PUT

- Include that 2000-byte size limits should work for
most components.

    This closes #599


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

Branch: refs/heads/feature/GEM-1483
Commit: 49123c475052d730dfba0b021736d82c5404446c
Parents: 658b20f
Author: Karen Miller <km...@pivotal.io>
Authored: Fri Jun 23 16:25:32 2017 -0700
Committer: Karen Miller <km...@pivotal.io>
Committed: Mon Jun 26 09:07:27 2017 -0700

----------------------------------------------------------------------
 geode-docs/rest_apps/put_multiple_values_for_keys.html.md.erb | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/49123c47/geode-docs/rest_apps/put_multiple_values_for_keys.html.md.erb
----------------------------------------------------------------------
diff --git a/geode-docs/rest_apps/put_multiple_values_for_keys.html.md.erb b/geode-docs/rest_apps/put_multiple_values_for_keys.html.md.erb
index fa17580..e0e0c03 100644
--- a/geode-docs/rest_apps/put_multiple_values_for_keys.html.md.erb
+++ b/geode-docs/rest_apps/put_multiple_values_for_keys.html.md.erb
@@ -100,4 +100,5 @@ Response-payload: null
 |---------------------------|----------------------------------------------------------------------------------------------------------------------------------|
 | 400 BAD REQUEST           | Returned if one or more of the supplied keys is an invalid format.                                                               |
 | 404 NOT FOUND             | Returned if the region is not found.                                                                                             |
+| 414 REQUEST URI TOO LONG  | Returned if the URI is longer than the system component can handle. Limiting the size to 2000 bytes will work for most components.   |
 | 500 INTERNAL SERVER ERROR | Error encountered at Geode server. Check the HTTP response body for a stack trace of the exception. |


[37/46] geode git commit: GEODE-3075: changes in response to feedback; refactor some.

Posted by zh...@apache.org.
GEODE-3075: changes in response to feedback; refactor some.

`AcceptorImpl.handleNewClientConnection` has had refactoring and should
be a bit more understandable.


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

Branch: refs/heads/feature/GEM-1483
Commit: c71c28dff7fd6d20798fadcbd6a1a15f055ae52e
Parents: cdcc4d9
Author: Galen OSullivan <go...@pivotal.io>
Authored: Mon Jun 19 17:48:53 2017 -0700
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Mon Jun 26 09:26:22 2017 -0700

----------------------------------------------------------------------
 .../geode/internal/cache/tier/Acceptor.java     |   2 +-
 .../cache/tier/sockets/AcceptorImpl.java        | 316 ++++++++++---------
 .../GenericProtocolServerConnection.java        |  85 +++++
 .../sockets/NewProtocolServerConnection.java    |  87 -----
 .../tier/sockets/ServerConnectionFactory.java   |   9 +-
 .../ServerConnectionFactoryIntegrationTest.java |  45 ++-
 .../sockets/ServerConnectionFactoryTest.java    |  15 +-
 7 files changed, 291 insertions(+), 268 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/c71c28df/geode-core/src/main/java/org/apache/geode/internal/cache/tier/Acceptor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/Acceptor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/Acceptor.java
index a95195a..e12a409 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/Acceptor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/Acceptor.java
@@ -74,7 +74,7 @@ public abstract class Acceptor {
   /**
    * For the new client-server protocol, which ignores the usual handshake mechanism.
    */
-  public static final byte CLIENT_TO_SERVER_NEW_PROTOCOL = (byte) 110;
+  public static final byte PROTOBUF_CLIENT_SERVER_PROTOCOL = (byte) 110;
 
   /**
    * The GFE version of the server.

http://git-wip-us.apache.org/repos/asf/geode/blob/c71c28df/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/AcceptorImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/AcceptorImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/AcceptorImpl.java
index 24efc93..50f7006 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/AcceptorImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/AcceptorImpl.java
@@ -94,7 +94,7 @@ import javax.net.ssl.SSLException;
 /**
  * Implements the acceptor thread on the bridge server. Accepts connections from the edge and starts
  * up threads to process requests from these.
- * 
+ *
  * @since GemFire 2.0.2
  */
 @SuppressWarnings("deprecation")
@@ -113,19 +113,29 @@ public class AcceptorImpl extends Acceptor implements Runnable {
    */
   private final ThreadPoolExecutor hsPool;
 
-  /** The port on which this acceptor listens for client connections */
+  /**
+   * The port on which this acceptor listens for client connections
+   */
   private final int localPort;
 
-  /** The server socket that handles requests for connections */
+  /**
+   * The server socket that handles requests for connections
+   */
   private ServerSocket serverSock = null;
 
-  /** The GemFire cache served up by this acceptor */
+  /**
+   * The GemFire cache served up by this acceptor
+   */
   protected final InternalCache cache;
 
-  /** Caches region information */
+  /**
+   * Caches region information
+   */
   private final CachedRegionHelper crHelper;
 
-  /** A lock to prevent close from occurring while creating a ServerConnection */
+  /**
+   * A lock to prevent close from occurring while creating a ServerConnection
+   */
   private final Object syncLock = new Object();
 
   /**
@@ -165,7 +175,9 @@ public class AcceptorImpl extends Acceptor implements Runnable {
    */
   public static final int DEFAULT_HANDSHAKE_TIMEOUT_MS = 59000;
 
-  /** Test value for handshake timeout */
+  /**
+   * Test value for handshake timeout
+   */
   protected static final int handShakeTimeout =
       Integer.getInteger(HANDSHAKE_TIMEOUT_PROPERTY_NAME, DEFAULT_HANDSHAKE_TIMEOUT_MS).intValue();
 
@@ -180,17 +192,25 @@ public class AcceptorImpl extends Acceptor implements Runnable {
    */
   public static final int DEFAULT_ACCEPT_TIMEOUT_MS = 9900;
 
-  /** Test value for accept timeout */
+  /**
+   * Test value for accept timeout
+   */
   private final int acceptTimeout =
       Integer.getInteger(ACCEPT_TIMEOUT_PROPERTY_NAME, DEFAULT_ACCEPT_TIMEOUT_MS).intValue();
 
-  /** The mininum value of max-connections */
+  /**
+   * The mininum value of max-connections
+   */
   public static final int MINIMUM_MAX_CONNECTIONS = 16;
 
-  /** The buffer size for server-side sockets. */
+  /**
+   * The buffer size for server-side sockets.
+   */
   private final int socketBufferSize;
 
-  /** Notifies clients of updates */
+  /**
+   * Notifies clients of updates
+   */
   private CacheClientNotifier clientNotifier;
 
   /**
@@ -198,7 +218,9 @@ public class AcceptorImpl extends Acceptor implements Runnable {
    */
   private static final int DEFAULT_BACKLOG = 1000;
 
-  /** The system property name for setting the {@link ServerSocket}backlog */
+  /**
+   * The system property name for setting the {@link ServerSocket}backlog
+   */
   public static final String BACKLOG_PROPERTY_NAME = "BridgeServer.backlog";
 
   /**
@@ -206,13 +228,19 @@ public class AcceptorImpl extends Acceptor implements Runnable {
    */
   public final AtomicInteger clientServerCnxCount = new AtomicInteger();
 
-  /** Has this acceptor been shut down */
+  /**
+   * Has this acceptor been shut down
+   */
   private volatile boolean shutdownStarted = false;
 
-  /** The thread that runs the acceptor */
+  /**
+   * The thread that runs the acceptor
+   */
   private Thread thread = null;
 
-  /** The thread that runs the selector loop if any */
+  /**
+   * The thread that runs the selector loop if any
+   */
   private Thread selectorThread = null;
 
   /**
@@ -222,16 +250,16 @@ public class AcceptorImpl extends Acceptor implements Runnable {
 
   /**
    * List of ServerConnection.
-   * 
+   *
    * Instances added when constructed; removed when terminated.
-   * 
+   *
    * guarded.By {@link #allSCsLock}
    */
   private final HashSet allSCs = new HashSet();
 
   /**
    * List of ServerConnections, for {@link #emergencyClose()}
-   * 
+   *
    * guarded.By {@link #allSCsLock}
    */
   private volatile ServerConnection allSCList[] = new ServerConnection[0];
@@ -239,7 +267,7 @@ public class AcceptorImpl extends Acceptor implements Runnable {
   /**
    * The ip address or host name this acceptor is to bind to; <code>null</code> or "" indicates it
    * will listen on all local addresses.
-   * 
+   *
    * @since GemFire 5.7
    */
   private final String bindHostName;
@@ -249,10 +277,14 @@ public class AcceptorImpl extends Acceptor implements Runnable {
    */
   private final ConnectionListener connectionListener;
 
-  /** The client health monitor tracking connections for this acceptor */
+  /**
+   * The client health monitor tracking connections for this acceptor
+   */
   private ClientHealthMonitor healthMonitor;
 
-  /** bridge's setting of notifyBySubscription */
+  /**
+   * bridge's setting of notifyBySubscription
+   */
   private final boolean notifyBySubscription;
 
   /**
@@ -273,7 +305,7 @@ public class AcceptorImpl extends Acceptor implements Runnable {
 
   /**
    * Initializes this acceptor thread to listen for connections on the given port.
-   * 
+   *
    * @param port The port on which this acceptor listens for connections. If <code>0</code>, a
    *        random port will be chosen.
    * @param bindHostName The ip address or host name this acceptor listens on for connections. If
@@ -284,7 +316,6 @@ public class AcceptorImpl extends Acceptor implements Runnable {
    * @param internalCache The GemFire cache whose contents is served to clients
    * @param maxConnections the maximum number of connections allowed in the server pool
    * @param maxThreads the maximum number of threads allowed in the server pool
-   * 
    * @see SocketCreator#createServerSocket(int, int, InetAddress)
    * @see ClientHealthMonitor
    * @since GemFire 5.7
@@ -615,7 +646,7 @@ public class AcceptorImpl extends Acceptor implements Runnable {
   /**
    * This system property is only used if max-threads == 0. This is for 5.0.2 backwards
    * compatibility.
-   * 
+   *
    * @deprecated since 5.1 use cache-server max-threads instead
    */
   @Deprecated
@@ -624,7 +655,7 @@ public class AcceptorImpl extends Acceptor implements Runnable {
   /**
    * This system property is only used if max-threads == 0. This is for 5.0.2 backwards
    * compatibility.
-   * 
+   *
    * @deprecated since 5.1 use cache-server max-threads instead
    */
   @Deprecated
@@ -693,7 +724,9 @@ public class AcceptorImpl extends Acceptor implements Runnable {
     wakeupSelector();
   }
 
-  /** wake up the selector thread */
+  /**
+   * wake up the selector thread
+   */
   private void wakeupSelector() {
     Selector s = getSelector();
     if (s != null && s.isOpen()) {
@@ -760,7 +793,7 @@ public class AcceptorImpl extends Acceptor implements Runnable {
 
   /**
    * Ensure that the CachedRegionHelper and ServerConnection classes get loaded.
-   * 
+   *
    * @see SystemFailure#loadEmergencyClasses()
    */
   public static void loadEmergencyClasses() {
@@ -1146,7 +1179,7 @@ public class AcceptorImpl extends Acceptor implements Runnable {
 
   /**
    * The work loop of this acceptor
-   * 
+   *
    * @see #accept
    */
   public void run() {
@@ -1369,156 +1402,145 @@ public class AcceptorImpl extends Acceptor implements Runnable {
     return this.clientServerCnxCount.get();
   }
 
-  protected void handleNewClientConnection(final Socket s) throws IOException {
+  protected void handleNewClientConnection(final Socket socket) throws IOException {
     // Read the first byte. If this socket is being used for 'client to server'
     // communication, create a ServerConnection. If this socket is being used
     // for 'server to client' communication, send it to the CacheClientNotifier
     // for processing.
     byte communicationMode;
     if (isSelector()) {
-      ByteBuffer bb = ByteBuffer.allocateDirect(1);
-      final SocketChannel sc = s.getChannel();
-      sc.configureBlocking(false);
+      ByteBuffer byteBuffer = ByteBuffer.allocateDirect(1);
+      final SocketChannel socketChannel = socket.getChannel();
+      socketChannel.configureBlocking(false);
       // try to read the byte first in non-blocking mode
-      int res = sc.read(bb);
-      sc.configureBlocking(true);
+      int res = socketChannel.read(byteBuffer);
+      socketChannel.configureBlocking(true);
       if (res < 0) {
         throw new EOFException();
       } else if (res == 0) {
         // now do a blocking read so setup a timer to close the socket if the
         // the read takes too long
-        SystemTimer.SystemTimerTask st = new SystemTimer.SystemTimerTask() {
+        SystemTimer.SystemTimerTask timerTask = new SystemTimer.SystemTimerTask() {
           @Override
           public void run2() {
             logger.warn(LocalizedMessage.create(
                 LocalizedStrings.AcceptorImpl_CACHE_SERVER_TIMED_OUT_WAITING_FOR_HANDSHAKE_FROM__0,
-                s.getRemoteSocketAddress()));
-            closeSocket(s);
+                socket.getRemoteSocketAddress()));
+            closeSocket(socket);
           }
         };
-        this.hsTimer.schedule(st, this.acceptTimeout);
-        res = sc.read(bb);
-        if ((!st.cancel()) || res <= 0) {
+        this.hsTimer.schedule(timerTask, this.acceptTimeout);
+        res = socketChannel.read(byteBuffer);
+        if ((!timerTask.cancel()) || res <= 0) {
           throw new EOFException();
         }
       }
-      communicationMode = bb.get(0);
-      if (logger.isTraceEnabled()) {
-        logger.trace("read communications mode(1) ", communicationMode);
-      }
+      communicationMode = byteBuffer.get(0);
     } else {
-      s.setSoTimeout(this.acceptTimeout);
-      this.socketCreator.configureServerSSLSocket(s);
-      communicationMode = (byte) s.getInputStream().read();
-      if (logger.isTraceEnabled()) {
-        logger.trace("read communications mode(2) ", communicationMode);
-      }
+      socket.setSoTimeout(this.acceptTimeout);
+      this.socketCreator.configureServerSSLSocket(socket);
+      communicationMode = (byte) socket.getInputStream().read();
       if (communicationMode == -1) {
         throw new EOFException();
       }
-      s.setSoTimeout(0);
+      socket.setSoTimeout(0);
     }
 
-    s.setTcpNoDelay(this.tcpNoDelay);
+    socket.setTcpNoDelay(this.tcpNoDelay);
 
-    if (communicationMode == CLIENT_TO_SERVER || communicationMode == GATEWAY_TO_GATEWAY
-        || communicationMode == MONITOR_TO_SERVER || communicationMode == CLIENT_TO_SERVER_FOR_QUEUE
-        || communicationMode == CLIENT_TO_SERVER_NEW_PROTOCOL) {
-      String communicationModeStr = "";
-      switch (communicationMode) {
-        case CLIENT_TO_SERVER:
-          communicationModeStr = "client";
-          break;
-        case GATEWAY_TO_GATEWAY:
-          communicationModeStr = "gateway";
-          break;
-        case MONITOR_TO_SERVER:
-          communicationModeStr = "monitor";
-          break;
-        case CLIENT_TO_SERVER_FOR_QUEUE:
-          communicationModeStr = "clientToServerForQueue";
-          break;
-      }
-      if (logger.isDebugEnabled()) {
-        logger.debug("Bridge server: Initializing {} communication socket: {}",
-            communicationModeStr, s);
+    String communicationModeStr;
+    switch (communicationMode) {
+      default:
+        throw new IOException("Acceptor received unknown communication mode: " + communicationMode);
+
+      case PRIMARY_SERVER_TO_CLIENT:
+        logger.debug(
+            ":Bridge server: Initializing primary server-to-client communication socket: {}",
+            socket);
+        AcceptorImpl.this.clientNotifier.registerClient(socket, true, this.acceptorId,
+            this.notifyBySubscription);
+        return;
+
+      case SECONDARY_SERVER_TO_CLIENT:
+        logger.debug(
+            ":Bridge server: Initializing secondary server-to-client communication socket: {}",
+            socket);
+        AcceptorImpl.this.clientNotifier.registerClient(socket, false, this.acceptorId,
+            this.notifyBySubscription);
+        return;
+
+      case CLIENT_TO_SERVER:
+        communicationModeStr = "client";
+        break;
+      case GATEWAY_TO_GATEWAY:
+        communicationModeStr = "gateway";
+        break;
+      case MONITOR_TO_SERVER:
+        communicationModeStr = "monitor";
+        break;
+      case CLIENT_TO_SERVER_FOR_QUEUE:
+        communicationModeStr = "clientToServerForQueue";
+        break;
+      case PROTOBUF_CLIENT_SERVER_PROTOCOL:
+        communicationModeStr = "Protobuf client";
+        break;
+    }
+
+    logger.debug("Bridge server: Initializing {} communication socket: {}", communicationModeStr,
+        socket);
+    if (communicationMode != CLIENT_TO_SERVER_FOR_QUEUE) {
+      int curCnt = this.getClientServerCnxCount();
+      if (curCnt >= this.maxConnections) {
+        logger.warn(LocalizedMessage.create(
+            LocalizedStrings.AcceptorImpl_REJECTED_CONNECTION_FROM_0_BECAUSE_CURRENT_CONNECTION_COUNT_OF_1_IS_GREATER_THAN_OR_EQUAL_TO_THE_CONFIGURED_MAX_OF_2,
+            new Object[] {socket.getInetAddress(), Integer.valueOf(curCnt),
+                Integer.valueOf(this.maxConnections)}));
+        try {
+          ServerHandShakeProcessor.refuse(socket.getOutputStream(),
+              LocalizedStrings.AcceptorImpl_EXCEEDED_MAX_CONNECTIONS_0
+                  .toLocalizedString(Integer.valueOf(this.maxConnections)));
+        } catch (Exception ex) {
+          logger.debug("rejection message failed", ex);
+        }
+        closeSocket(socket);
+        return;
       }
-      if (communicationMode != CLIENT_TO_SERVER_FOR_QUEUE) {
-        int curCnt = this.getClientServerCnxCount();
-        if (curCnt >= this.maxConnections) {
-          logger.warn(LocalizedMessage.create(
-              LocalizedStrings.AcceptorImpl_REJECTED_CONNECTION_FROM_0_BECAUSE_CURRENT_CONNECTION_COUNT_OF_1_IS_GREATER_THAN_OR_EQUAL_TO_THE_CONFIGURED_MAX_OF_2,
-              new Object[] {s.getInetAddress(), Integer.valueOf(curCnt),
-                  Integer.valueOf(this.maxConnections)}));
-          // if (s != null) (cannot be null)
-          {
-            try {
-              ServerHandShakeProcessor.refuse(s.getOutputStream(),
-                  LocalizedStrings.AcceptorImpl_EXCEEDED_MAX_CONNECTIONS_0
-                      .toLocalizedString(Integer.valueOf(this.maxConnections)));
-            } catch (Exception ex) {
-              if (logger.isDebugEnabled()) {
-                logger.debug("rejection message failed", ex);
-              }
-            }
-            closeSocket(s);
-          }
+    }
+
+    ServerConnection serverConn = ServerConnectionFactory.makeServerConnection(socket, this.cache,
+        this.crHelper, this.stats, AcceptorImpl.handShakeTimeout, this.socketBufferSize,
+        communicationModeStr, communicationMode, this, this.securityService);
+
+    synchronized (this.allSCsLock) {
+      this.allSCs.add(serverConn);
+      ServerConnection snap[] = this.allSCList; // avoid volatile read
+      this.allSCList = (ServerConnection[]) ArrayUtils.insert(snap, snap.length, serverConn);
+    }
+    if (communicationMode != CLIENT_TO_SERVER_FOR_QUEUE) {
+      incClientServerCnxCount();
+    }
+    if (isSelector()) {
+      serverConn.registerWithSelector();
+    } else {
+      try {
+        pool.execute(serverConn);
+      } catch (RejectedExecutionException rejected) {
+        if (!isRunning()) {
           return;
         }
-      }
-      ServerConnection serverConn = ServerConnectionFactory.makeServerConnection(s, this.cache,
-          this.crHelper, this.stats, AcceptorImpl.handShakeTimeout, this.socketBufferSize,
-          communicationModeStr, communicationMode, this, this.securityService);
-      synchronized (this.allSCsLock) {
-        this.allSCs.add(serverConn);
-        ServerConnection snap[] = this.allSCList; // avoid volatile read
-        this.allSCList = (ServerConnection[]) ArrayUtils.insert(snap, snap.length, serverConn);
-      }
-      if (communicationMode != CLIENT_TO_SERVER_FOR_QUEUE) {
-        incClientServerCnxCount();
-      }
-      if (isSelector()) {
-        serverConn.registerWithSelector();
-      } else {
+        logger.warn(LocalizedMessage.create(
+            LocalizedStrings.AcceptorImpl_REJECTED_CONNECTION_FROM_0_BECAUSE_REQUEST_REJECTED_BY_POOL,
+            new Object[] {serverConn}));
         try {
-          pool.execute(serverConn);
-        } catch (RejectedExecutionException rejected) {
-          if (!isRunning()) {
-            return;
-          }
-          logger.warn(LocalizedMessage.create(
-              LocalizedStrings.AcceptorImpl_REJECTED_CONNECTION_FROM_0_BECAUSE_REQUEST_REJECTED_BY_POOL,
-              new Object[] {serverConn}));
-          try {
-            ServerHandShakeProcessor.refuse(s.getOutputStream(),
-                LocalizedStrings.AcceptorImpl_EXCEEDED_MAX_CONNECTIONS_0
-                    .toLocalizedString(Integer.valueOf(this.maxConnections)));
+          ServerHandShakeProcessor.refuse(socket.getOutputStream(),
+              LocalizedStrings.AcceptorImpl_EXCEEDED_MAX_CONNECTIONS_0
+                  .toLocalizedString(Integer.valueOf(this.maxConnections)));
 
-          } catch (Exception ex) {
-            if (logger.isDebugEnabled()) {
-              logger.debug("rejection message failed", ex);
-            }
-          }
-          serverConn.cleanup();
+        } catch (Exception ex) {
+          logger.debug("rejection message failed", ex);
         }
+        serverConn.cleanup();
       }
-    } else if (communicationMode == PRIMARY_SERVER_TO_CLIENT) {
-      if (logger.isDebugEnabled()) {
-        logger.debug(
-            ":Bridge server: Initializing primary server-to-client communication socket: {}", s);
-      }
-      // try {
-      AcceptorImpl.this.clientNotifier.registerClient(s, true, this.acceptorId,
-          this.notifyBySubscription);
-    } else if (communicationMode == SECONDARY_SERVER_TO_CLIENT) {
-      if (logger.isDebugEnabled()) {
-        logger.debug(
-            ":Bridge server: Initializing secondary server-to-client communication socket: {}", s);
-      }
-      AcceptorImpl.this.clientNotifier.registerClient(s, false, this.acceptorId,
-          this.notifyBySubscription);
-    } else {
-      throw new IOException("Acceptor received unknown communication mode: " + communicationMode);
     }
   }
 
@@ -1645,7 +1667,7 @@ public class AcceptorImpl extends Acceptor implements Runnable {
    *        then calculate it.
    * @return the ip address or host name this acceptor will listen on. An "" if all local addresses
    *         will be listened to.
-   * 
+   *
    * @since GemFire 5.7
    */
   private static String calcBindHostName(Cache cache, String bindName) {
@@ -1682,7 +1704,7 @@ public class AcceptorImpl extends Acceptor implements Runnable {
 
   /**
    * Gets the address that this bridge server can be contacted on from external processes.
-   * 
+   *
    * @since GemFire 5.7
    */
   public String getExternalAddress() {
@@ -1716,7 +1738,7 @@ public class AcceptorImpl extends Acceptor implements Runnable {
   /**
    * This method finds a client notifier and returns it. It is used to propagate interest
    * registrations to other servers
-   * 
+   *
    * @return the instance that provides client notification
    */
   public CacheClientNotifier getCacheClientNotifier() {
@@ -1773,7 +1795,7 @@ public class AcceptorImpl extends Acceptor implements Runnable {
    * This method returns a thread safe structure which can be iterated over without worrying about
    * ConcurrentModificationException. JMX MBeans/Commands need to iterate over this list to get
    * client info.
-   * 
+   *
    */
   public ServerConnection[] getAllServerConnectionList() {
     return this.allSCList;

http://git-wip-us.apache.org/repos/asf/geode/blob/c71c28df/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/GenericProtocolServerConnection.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/GenericProtocolServerConnection.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/GenericProtocolServerConnection.java
new file mode 100644
index 0000000..8edd83c
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/GenericProtocolServerConnection.java
@@ -0,0 +1,85 @@
+/*
+ * 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.internal.cache.tier.sockets;
+
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.cache.tier.Acceptor;
+import org.apache.geode.internal.cache.tier.CachedRegionHelper;
+import org.apache.geode.internal.security.SecurityService;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+
+/**
+ * Holds the socket and protocol handler for the new client protocol. TODO: Currently unimplemented
+ * due the the protocol not being there.
+ */
+public class GenericProtocolServerConnection extends ServerConnection {
+  // The new protocol lives in a separate module and gets loaded when this class is instantiated.
+  // TODO implement this.
+  private final ClientProtocolMessageHandler messageHandler;
+
+  /**
+   * Creates a new <code>GenericProtocolServerConnection</code> that processes messages received
+   * from an edge client over a given <code>Socket</code>.
+   *
+   * @param s
+   * @param c
+   * @param helper
+   * @param stats
+   * @param hsTimeout
+   * @param socketBufferSize
+   * @param communicationModeStr
+   * @param communicationMode
+   * @param acceptor
+   */
+  public GenericProtocolServerConnection(Socket s, InternalCache c, CachedRegionHelper helper,
+      CacheServerStats stats, int hsTimeout, int socketBufferSize, String communicationModeStr,
+      byte communicationMode, Acceptor acceptor, ClientProtocolMessageHandler newClientProtocol,
+      SecurityService securityService) {
+    super(s, c, helper, stats, hsTimeout, socketBufferSize, communicationModeStr, communicationMode,
+        acceptor, securityService);
+    this.messageHandler = newClientProtocol;
+  }
+
+  @Override
+  protected void doOneMessage() {
+    try {
+      Socket socket = this.getSocket();
+      InputStream inputStream = socket.getInputStream();
+      OutputStream outputStream = socket.getOutputStream();
+
+      // TODO serialization types?
+      messageHandler.receiveMessage(inputStream, outputStream, this.getCache());
+    } catch (IOException e) {
+      // TODO?
+    }
+    return;
+  }
+
+  @Override
+  protected boolean doHandShake(byte epType, int qSize) {
+    // no handshake for new client protocol.
+    return true;
+  }
+
+  @Override
+  public boolean isClientServerConnection() {
+    return true;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/c71c28df/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/NewProtocolServerConnection.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/NewProtocolServerConnection.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/NewProtocolServerConnection.java
deleted file mode 100644
index 83b23b1..0000000
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/NewProtocolServerConnection.java
+++ /dev/null
@@ -1,87 +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.internal.cache.tier.sockets;
-
-import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.internal.cache.tier.Acceptor;
-import org.apache.geode.internal.cache.tier.CachedRegionHelper;
-import org.apache.geode.internal.security.SecurityService;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.Socket;
-
-/**
- * Holds the socket and protocol handler for the new client protocol. TODO: Currently unimplemented
- * due the the protocol not being there.
- */
-public class NewProtocolServerConnection extends ServerConnection {
-  // The new protocol lives in a separate module and gets loaded when this class is instantiated.
-  // TODO implement this.
-  private final ClientProtocolMessageHandler newClientProtocol;
-
-
-  /**
-   * Creates a new <code>NewProtocolServerConnection</code> that processes messages received from an
-   * edge client over a given <code>Socket</code>.
-   *
-   * @param s
-   * @param c
-   * @param helper
-   * @param stats
-   * @param hsTimeout
-   * @param socketBufferSize
-   * @param communicationModeStr
-   * @param communicationMode
-   * @param acceptor
-   */
-  public NewProtocolServerConnection(Socket s, InternalCache c, CachedRegionHelper helper,
-      CacheServerStats stats, int hsTimeout, int socketBufferSize, String communicationModeStr,
-      byte communicationMode, Acceptor acceptor, ClientProtocolMessageHandler newClientProtocol,
-      SecurityService securityService) {
-    super(s, c, helper, stats, hsTimeout, socketBufferSize, communicationModeStr, communicationMode,
-        acceptor, securityService);
-    assert (communicationMode == AcceptorImpl.CLIENT_TO_SERVER_NEW_PROTOCOL);
-    this.newClientProtocol = newClientProtocol;
-  }
-
-  @Override
-  protected void doOneMessage() {
-    try {
-      Socket socket = this.getSocket();
-      InputStream inputStream = socket.getInputStream();
-      OutputStream outputStream = socket.getOutputStream();
-
-      // TODO serialization types?
-      newClientProtocol.receiveMessage(inputStream, outputStream, this.getCache());
-    } catch (IOException e) {
-      // TODO?
-    }
-    return;
-  }
-
-  @Override
-  protected boolean doHandShake(byte epType, int qSize) {
-    // no handshake for new client protocol.
-    return true;
-  }
-
-  @Override
-  public boolean isClientServerConnection() {
-    return true;
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/c71c28df/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactory.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactory.java
index 4f2e304..e4746a7 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactory.java
@@ -28,19 +28,20 @@ import java.net.Socket;
  */
 public class ServerConnectionFactory {
   // TODO: implement ClientProtocolMessageHandler.
-  private static final ClientProtocolMessageHandler newClientProtocol =
+  private static final ClientProtocolMessageHandler protobufProtocolHandler =
       new ClientProtocolMessageHandler();
 
   public static ServerConnection makeServerConnection(Socket s, InternalCache c,
       CachedRegionHelper helper, CacheServerStats stats, int hsTimeout, int socketBufferSize,
       String communicationModeStr, byte communicationMode, Acceptor acceptor,
       SecurityService securityService) throws IOException {
-    if (communicationMode == Acceptor.CLIENT_TO_SERVER_NEW_PROTOCOL) {
+    if (communicationMode == Acceptor.PROTOBUF_CLIENT_SERVER_PROTOCOL) {
       if (!Boolean.getBoolean("geode.feature-protobuf-protocol")) {
         throw new IOException("Acceptor received unknown communication mode: " + communicationMode);
       } else {
-        return new NewProtocolServerConnection(s, c, helper, stats, hsTimeout, socketBufferSize,
-            communicationModeStr, communicationMode, acceptor, newClientProtocol, securityService);
+        return new GenericProtocolServerConnection(s, c, helper, stats, hsTimeout, socketBufferSize,
+            communicationModeStr, communicationMode, acceptor, protobufProtocolHandler,
+            securityService);
       }
     } else {
       return new LegacyServerConnection(s, c, helper, stats, hsTimeout, socketBufferSize,

http://git-wip-us.apache.org/repos/asf/geode/blob/c71c28df/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java
index 007d1d6..82c4e54 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryIntegrationTest.java
@@ -15,6 +15,8 @@
 
 package org.apache.geode.internal.cache.tier.sockets;
 
+import static org.junit.Assert.assertEquals;
+
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.server.CacheServer;
@@ -22,45 +24,42 @@ import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.internal.cache.tier.Acceptor;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.awaitility.Awaitility;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
 import org.junit.experimental.categories.Category;
 
 import java.io.IOException;
 import java.net.Socket;
 import java.util.concurrent.TimeUnit;
 
-import static org.junit.Assert.assertEquals;
-
 /**
- * Test that switching on the header byte makes instances of {@link NewProtocolServerConnection}.
+ * Test that switching on the header byte makes instances of
+ * {@link GenericProtocolServerConnection}.
  */
 @Category(IntegrationTest.class)
 public class ServerConnectionFactoryIntegrationTest {
-  /**
-   *
-   * @throws IOException
-   */
+
+  @Rule
+  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+
   @Test
   public void testNewProtocolHeaderLeadsToNewProtocolServerConnection() throws IOException {
     System.setProperty("geode.feature-protobuf-protocol", "true");
-    try {
-      CacheFactory cacheFactory = new CacheFactory();
-      Cache cache = cacheFactory.create();
+    CacheFactory cacheFactory = new CacheFactory();
+    Cache cache = cacheFactory.create();
 
-      CacheServer cacheServer = cache.addCacheServer();
-      final int cacheServerPort = AvailablePortHelper.getRandomAvailableTCPPort();
-      cacheServer.setPort(cacheServerPort);
-      cacheServer.start();
+    CacheServer cacheServer = cache.addCacheServer();
+    final int cacheServerPort = AvailablePortHelper.getRandomAvailableTCPPort();
+    cacheServer.setPort(cacheServerPort);
+    cacheServer.start();
 
-      Socket socket = new Socket("localhost", cacheServerPort);
-      Awaitility.await().atMost(5, TimeUnit.SECONDS).until(socket::isConnected);
-      socket.getOutputStream().write(Acceptor.CLIENT_TO_SERVER_NEW_PROTOCOL);
-      socket.getOutputStream().write(222);
-      assertEquals(222, socket.getInputStream().read());
+    Socket socket = new Socket("localhost", cacheServerPort);
+    Awaitility.await().atMost(5, TimeUnit.SECONDS).until(socket::isConnected);
+    socket.getOutputStream().write(Acceptor.PROTOBUF_CLIENT_SERVER_PROTOCOL);
+    socket.getOutputStream().write(222);
+    assertEquals(222, socket.getInputStream().read());
 
-      cache.close();
-    } finally {
-      System.clearProperty("geode.feature-protobuf-protocol");
-    }
+    cache.close();
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/c71c28df/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java
index 8e241b2..11b5289 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ServerConnectionFactoryTest.java
@@ -39,16 +39,19 @@ public class ServerConnectionFactoryTest {
    */
   @Test(expected = IOException.class)
   public void newClientProtocolThrows() throws Exception {
-    serverConnectionMockedExceptForCommunicationMode(Acceptor.CLIENT_TO_SERVER_NEW_PROTOCOL);
+    serverConnectionMockedExceptForCommunicationMode(Acceptor.PROTOBUF_CLIENT_SERVER_PROTOCOL);
   }
 
   @Test
   public void newClientProtocolSucceedsWithSystemPropertySet() throws Exception {
-    System.setProperty("geode.feature-protobuf-protocol", "true");
-    ServerConnection serverConnection =
-        serverConnectionMockedExceptForCommunicationMode(Acceptor.CLIENT_TO_SERVER_NEW_PROTOCOL);
-    assertTrue(serverConnection instanceof NewProtocolServerConnection);
-    System.clearProperty("geode.feature-protobuf-protocol");
+    try {
+      System.setProperty("geode.feature-protobuf-protocol", "true");
+      ServerConnection serverConnection = serverConnectionMockedExceptForCommunicationMode(
+          Acceptor.PROTOBUF_CLIENT_SERVER_PROTOCOL);
+      assertTrue(serverConnection instanceof GenericProtocolServerConnection);
+    } finally {
+      System.clearProperty("geode.feature-protobuf-protocol");
+    }
   }
 
   @Test


[22/46] geode git commit: GEODE-3052 Restarting 2 locators together causes potential locator split brain

Posted by zh...@apache.org.
GEODE-3052 Restarting 2 locators together causes potential locator split brain

There were four problems that new unit tests hit:
1. when recovering a view from disk we were treating it as a definitive
(live) view.  I've moved it to a new variable in GMSLocator and set its
viewId to -1.  At the same time I set the initial GMSJoinLeave
SearchState.viewId to -100 so it will be overridden by the one returned
by the locator.  These changes allow GmsJoinLeave to know that the
potential coordinator is from a recovered view.

2. when trying to join with a recovered view GMSJoinLeave.join() was giving
up after the second ID in the view and becoming the coordinator.  It needs
to keep trying until the list is exhausted, and it shouldn't sleep between
attempts.

3. GMSLocator wasn't returning registrants for use in
findCoordinatorFromView().  This was causing it to choose itself as
the coordinator instead of using registrant sort order and choosing
a different registrant as the coordinator.

4. During concurrent startup GMSLocator didn't know when the decision
was made to become coordinator.  It is now notified of this decision
and processRequest() uses this flag to have it override anything in
the registrants set or in the recovered view.


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

Branch: refs/heads/feature/GEM-1483
Commit: 3ee585c5844607e5da9756afb089405a30ae3dd3
Parents: 6f60785
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Thu Jun 22 13:50:26 2017 -0700
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Thu Jun 22 13:54:55 2017 -0700

----------------------------------------------------------------------
 .../internal/membership/NetView.java            |   4 +
 .../internal/membership/gms/GMSUtil.java        |  15 +-
 .../membership/gms/interfaces/Locator.java      |   5 +
 .../gms/locator/FindCoordinatorResponse.java    |   2 +-
 .../membership/gms/locator/GMSLocator.java      |  52 +++-
 .../membership/gms/membership/GMSJoinLeave.java |  92 ++++--
 .../membership/gms/messenger/GMSEncrypt.java    |  14 +-
 .../gms/messenger/JGroupsMessenger.java         |   2 +-
 .../geode/distributed/LocatorDUnitTest.java     | 298 +++++++++++++------
 .../LocatorUDPSecurityDUnitTest.java            |   8 +
 .../gms/membership/GMSJoinLeaveTestHelper.java  |  16 +-
 .../gms/messenger/GMSEncryptJUnitTest.java      |   1 -
 12 files changed, 360 insertions(+), 149 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/3ee585c5/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/NetView.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/NetView.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/NetView.java
index 26b0327..c935074 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/NetView.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/NetView.java
@@ -165,6 +165,10 @@ public class NetView implements DataSerializableFixedID {
     }
   }
 
+  public void setViewId(int viewId) {
+    this.viewId = viewId;
+  }
+
 
 
   public int[] getFailureDetectionPorts() {

http://git-wip-us.apache.org/repos/asf/geode/blob/3ee585c5/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSUtil.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSUtil.java
index c6bef57..da295ab 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSUtil.java
@@ -28,6 +28,13 @@ import org.apache.geode.internal.net.SocketCreator;
 
 public class GMSUtil {
 
+  /**
+   * parse locators & check that the resulting address is compatible with the given address
+   * 
+   * @param locatorsString a DistributionConfig "locators" string
+   * @param bindAddress optional address to check for loopback compatibility
+   * @return addresses of locators
+   */
   public static List<InetSocketAddress> parseLocators(String locatorsString, String bindAddress) {
     InetAddress addr = null;
 
@@ -43,7 +50,13 @@ public class GMSUtil {
     return parseLocators(locatorsString, addr);
   }
 
-
+  /**
+   * parse locators & check that the resulting address is compatible with the given address
+   * 
+   * @param locatorsString a DistributionConfig "locators" string
+   * @param bindAddress optional address to check for loopback compatibility
+   * @return addresses of locators
+   */
   public static List<InetSocketAddress> parseLocators(String locatorsString,
       InetAddress bindAddress) {
     List<InetSocketAddress> result = new ArrayList<>(2);

http://git-wip-us.apache.org/repos/asf/geode/blob/3ee585c5/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/interfaces/Locator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/interfaces/Locator.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/interfaces/Locator.java
index c5fdf45..a365143 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/interfaces/Locator.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/interfaces/Locator.java
@@ -26,4 +26,9 @@ public interface Locator {
    */
   void installView(NetView v);
 
+  /**
+   * informs the locator that this process is becoming the membership coordinator
+   */
+  void setIsCoordinator(boolean isCoordinator);
+
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/3ee585c5/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/FindCoordinatorResponse.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/FindCoordinatorResponse.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/FindCoordinatorResponse.java
index edfaf62..550d555 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/FindCoordinatorResponse.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/FindCoordinatorResponse.java
@@ -129,7 +129,7 @@ public class FindCoordinatorResponse extends HighPriorityDistributionMessage
     } else {
       return "FindCoordinatorResponse(coordinator=" + coordinator + ", fromView=" + fromView
           + ", viewId=" + (view == null ? "null" : view.getViewId()) + ", registrants="
-          + (registrants == null ? 0 : registrants.size()) + ", senderId=" + senderId
+          + (registrants == null ? "none" : registrants) + ", senderId=" + senderId
           + ", network partition detection enabled=" + this.networkPartitionDetectionEnabled
           + ", locators preferred as coordinators=" + this.usePreferredCoordinators + ")";
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/3ee585c5/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java
index 93fa9da..aff1938 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java
@@ -83,8 +83,12 @@ public class GMSLocator implements Locator, NetLocator {
    */
   private transient NetView view;
 
+  private transient NetView recoveredView;
+
   private File viewFile;
 
+  private volatile boolean isCoordinator;
+
   /**
    * @param bindAddress network address that TcpServer will bind to
    * @param stateFile the file to persist state to/recover from
@@ -122,6 +126,10 @@ public class GMSLocator implements Locator, NetLocator {
       NetView newView = services.getJoinLeave().getView();
       if (newView != null) {
         this.view = newView;
+      } else if (localAddress != null) {
+        synchronized (this.registrants) {
+          this.registrants.add(localAddress);
+        }
       }
       this.notifyAll();
       return true;
@@ -158,9 +166,14 @@ public class GMSLocator implements Locator, NetLocator {
     }
     logger.info("Peer locator received new membership view: " + view);
     this.view = view;
+    this.recoveredView = null;
     saveView(view);
   }
 
+  @Override
+  public void setIsCoordinator(boolean isCoordinator) {
+    this.isCoordinator = isCoordinator;
+  }
 
   @Override
   public Object processRequest(Object request) throws IOException {
@@ -218,6 +231,13 @@ public class GMSLocator implements Locator, NetLocator {
 
         boolean fromView = false;
         NetView v = this.view;
+        if (v == null) {
+          v = this.recoveredView;
+        }
+
+        synchronized (registrants) {
+          registrants.add(findRequest.getMemberID());
+        }
 
         if (v != null) {
           // if the ID of the requester matches an entry in the membership view then remove
@@ -231,8 +251,8 @@ public class GMSLocator implements Locator, NetLocator {
               break;
             }
           }
-          int viewId = v.getViewId();
-          if (viewId > findRequest.getLastViewId()) {
+
+          if (v.getViewId() > findRequest.getLastViewId()) {
             // ignore the requests rejectedCoordinators if the view has changed
             coord = v.getCoordinator(Collections.emptyList());
           } else {
@@ -249,7 +269,6 @@ public class GMSLocator implements Locator, NetLocator {
             rejections = Collections.emptyList();
           }
           synchronized (registrants) {
-            registrants.add(findRequest.getMemberID());
             coord = services.getJoinLeave().getMemberID();
             for (InternalDistributedMember mbr : registrants) {
               if (mbr != coord && (coord == null || mbr.compareTo(coord) < 0)) {
@@ -264,14 +283,26 @@ public class GMSLocator implements Locator, NetLocator {
         }
 
         synchronized (registrants) {
+          if (isCoordinator) {
+            coord = localAddress;
+            InternalDistributedMember viewCoordinator = null;
+            if (v != null) {
+              viewCoordinator = v.getCoordinator();
+            }
+            fromView = viewCoordinator != null && !viewCoordinator.equals(localAddress);
+            if (!fromView) {
+              logger.info("This member is becoming coordinator");
+              v = null;
+            }
+          }
           byte[] coordPk = null;
-          if (view != null) {
-            coordPk = (byte[]) view.getPublicKey(coord);
+          if (v != null) {
+            coordPk = (byte[]) v.getPublicKey(coord);
           }
           if (coordPk == null) {
             coordPk = services.getMessenger().getPublicKey(coord);
           }
-          response = new FindCoordinatorResponse(coord, localAddress, fromView, view,
+          response = new FindCoordinatorResponse(coord, localAddress, fromView, v,
               new HashSet<InternalDistributedMember>(registrants),
               this.networkPartitionDetectionEnabled, this.usePreferredCoordinators, coordPk);
         }
@@ -405,17 +436,18 @@ public class GMSLocator implements Locator, NetLocator {
       }
 
       Object o = DataSerializer.readObject(ois2);
-      this.view = (NetView) o;
-      List<InternalDistributedMember> members = new ArrayList<>(view.getMembers());
+      recoveredView = (NetView) o;
+      recoveredView.setViewId(-1); // this is not a valid view so it shouldn't have a usable Id
+      List<InternalDistributedMember> members = new ArrayList<>(recoveredView.getMembers());
       // GEODE-3052 - remove locators from the view. Since we couldn't recover from an existing
       // locator we know that all of the locators in the view are defunct
       for (InternalDistributedMember member : members) {
         if (member.getVmKind() == DistributionManager.LOCATOR_DM_TYPE) {
-          view.remove(member);
+          recoveredView.remove(member);
         }
       }
 
-      logger.info("Peer locator initial membership is " + view);
+      logger.info("Peer locator recovered membership is " + recoveredView);
       return true;
 
     } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/geode/blob/3ee585c5/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
index 8abcc45..bc3d708 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
@@ -147,7 +147,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
   /**
    * guarded by viewInstallationLock
    */
-  private boolean isCoordinator;
+  private volatile boolean isCoordinator;
 
   /**
    * a synch object that guards view installation
@@ -261,7 +261,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
     Set<InternalDistributedMember> alreadyTried = new HashSet<>();
     Set<InternalDistributedMember> registrants = new HashSet<>();
     InternalDistributedMember possibleCoordinator;
-    int viewId = -1;
+    int viewId = -100;
     int locatorsContacted = 0;
     boolean hasContactedAJoinedLocator;
     NetView view;
@@ -275,6 +275,17 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
         responses.clear();
       }
     }
+
+    public String toString() {
+      StringBuffer sb = new StringBuffer(200);
+      sb.append("SearchState(locatorsContacted=").append(locatorsContacted)
+          .append("; alreadyTried=").append(alreadyTried).append("; registrants=")
+          .append(registrants).append("; possibleCoordinator=").append(possibleCoordinator)
+          .append("; viewId=").append(viewId).append("; hasContactedAJoinedLocator=")
+          .append(hasContactedAJoinedLocator).append("; view=").append(view).append("; responses=")
+          .append(responses).append(")");
+      return sb.toString();
+    }
   }
 
   Object getViewInstallationLock() {
@@ -313,6 +324,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
       for (int tries = 0; !this.isJoined && !this.isStopping; tries++) {
         logger.debug("searching for the membership coordinator");
         boolean found = findCoordinator();
+        logger.debug("state after looking for membership coordinator is {}", state);
         if (found) {
           logger.debug("found possible coordinator {}", state.possibleCoordinator);
           if (localAddress.getNetMember().preferredForCoordinator()
@@ -341,7 +353,6 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
               // break out of the loop and return false
               break;
             }
-            // reset the tries count and timer since we haven't actually tried to join yet
             tries = 0;
             giveupTime = now + timeout;
           } else if (now > giveupTime) {
@@ -349,9 +360,19 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
           }
         }
         try {
-          logger.debug("sleeping for {} before making another attempt to find the coordinator",
-              retrySleep);
-          Thread.sleep(retrySleep);
+          if (found && !state.hasContactedAJoinedLocator) {
+            // if locators are restarting they may be handing out IDs from a stale view that
+            // we should go through quickly. Otherwise we should sleep a bit to let failure
+            // detection select a new coordinator
+            if (state.possibleCoordinator.getVmViewId() < 0) {
+              logger.debug("sleeping for {} before making another attempt to find the coordinator",
+                  retrySleep);
+              Thread.sleep(retrySleep);
+            }
+            // since we were given a coordinator that couldn't be used we should keep trying
+            tries = 0;
+            giveupTime = System.currentTimeMillis() + timeout;
+          }
         } catch (InterruptedException e) {
           logger.debug("retry sleep interrupted - giving up on joining the distributed system");
           return false;
@@ -681,19 +702,26 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
   }
 
   private void recordViewRequest(DistributionMessage request) {
-    logger.debug("Recording the request to be processed in the next membership view");
-    synchronized (viewRequests) {
-      viewRequests.add(request);
-      if (viewCreator != null && services.getMessenger().getClusterSecretKey() != null) {
+    try {
+      synchronized (viewRequests) {
         if (request instanceof JoinRequestMessage) {
-          JoinRequestMessage jreq = (JoinRequestMessage) request;
-          // this will inform about cluster-secret key, as we have authenticated at this point
-          JoinResponseMessage response = new JoinResponseMessage(jreq.getSender(),
-              services.getMessenger().getClusterSecretKey(), jreq.getRequestId());
-          services.getMessenger().send(response);
+          if (isCoordinator
+              && !services.getConfig().getDistributionConfig().getSecurityUDPDHAlgo().isEmpty()) {
+            services.getMessenger().initClusterKey();
+            JoinRequestMessage jreq = (JoinRequestMessage) request;
+            // this will inform about cluster-secret key, as we have authenticated at this point
+            JoinResponseMessage response = new JoinResponseMessage(jreq.getSender(),
+                services.getMessenger().getClusterSecretKey(), jreq.getRequestId());
+            services.getMessenger().send(response);
+          }
         }
+        logger.debug("Recording the request to be processed in the next membership view");
+        viewRequests.add(request);
+        viewRequests.notifyAll();
       }
-      viewRequests.notifyAll();
+    } catch (RuntimeException | Error t) {
+      logger.warn("unable to record a membership view request due to this exception", t);
+      throw t;
     }
 
   }
@@ -744,6 +772,11 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
 
     logger.info("This member is becoming the membership coordinator with address {}", localAddress);
     isCoordinator = true;
+    org.apache.geode.distributed.internal.membership.gms.interfaces.Locator locator =
+        services.getLocator();
+    if (locator != null) {
+      locator.setIsCoordinator(true);
+    }
     if (currentView == null) {
       // create the initial membership view
       NetView newView = new NetView(this.localAddress);
@@ -764,12 +797,12 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
 
   private void createAndStartViewCreator(NetView newView) {
     if (viewCreator == null || viewCreator.isShutdown()) {
+      services.getMessenger().initClusterKey();
       viewCreator = new ViewCreator("Geode Membership View Creator", Services.getThreadGroup());
       if (newView != null) {
         viewCreator.setInitialView(newView, newView.getNewMembers(), newView.getShutdownMembers(),
             newView.getCrashedMembers());
       }
-      services.getMessenger().initClusterKey();
       viewCreator.setDaemon(true);
       logger.info("ViewCreator starting on:" + localAddress);
       viewCreator.start();
@@ -1041,7 +1074,8 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
     // haven't joined the system (e.g., a collocated locator)
     // then jump to using the membership view to try to find
     // the coordinator
-    if (!state.hasContactedAJoinedLocator && state.view != null) {
+    if (!state.hasContactedAJoinedLocator && state.registrants.size() >= locators.size()
+        && state.view != null) {
       return findCoordinatorFromView();
     }
 
@@ -1075,6 +1109,9 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
             }
             setCoordinatorPublicKey(response);
             state.locatorsContacted++;
+            if (response.getRegistrants() != null) {
+              state.registrants.addAll(response.getRegistrants());
+            }
             if (!state.hasContactedAJoinedLocator && response.getSenderId() != null
                 && response.getSenderId().getVmViewId() >= 0) {
               logger.debug("Locator's address indicates it is part of a distributed system "
@@ -1089,9 +1126,6 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
                 state.viewId = viewId;
                 state.view = v;
                 state.registrants.clear();
-                if (response.getRegistrants() != null) {
-                  state.registrants.addAll(response.getRegistrants());
-                }
               }
               if (viewId > -1) {
                 coordinatorsWithView.add(response.getCoordinator());
@@ -1165,6 +1199,8 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
     NetView v = state.view;
     List<InternalDistributedMember> recipients = new ArrayList<>(v.getMembers());
 
+    logger.debug("searching for coordinator in findCoordinatorFromView");
+
     if (recipients.size() > MAX_DISCOVERY_NODES && MAX_DISCOVERY_NODES > 0) {
       recipients = recipients.subList(0, MAX_DISCOVERY_NODES);
     }
@@ -1173,11 +1209,6 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
     }
     recipients.remove(localAddress);
 
-    // FindCoordinatorRequest req = new FindCoordinatorRequest(localAddress, state.alreadyTried,
-    // state.viewId, services.getMessenger().getPublickey(
-    // localAddress), services.getMessenger().getRequestId());
-    // req.setRecipients(v.getMembers());
-
     boolean testing = unitTesting.contains("findCoordinatorFromView");
     synchronized (state.responses) {
       if (!testing) {
@@ -1189,7 +1220,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
         // Here we are sending message one-by-one to all recipients as we don't have cluster secret
         // key yet.
         // Usually this happens when locator re-joins the cluster and it has saved view.
-        for (InternalDistributedMember mbr : v.getMembers()) {
+        for (InternalDistributedMember mbr : recipients) {
           Set<InternalDistributedMember> r = new HashSet<>();
           r.add(mbr);
           FindCoordinatorRequest req = new FindCoordinatorRequest(localAddress, state.alreadyTried,
@@ -1203,7 +1234,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
         FindCoordinatorRequest req = new FindCoordinatorRequest(localAddress, state.alreadyTried,
             state.viewId, services.getMessenger().getPublicKey(localAddress),
             services.getMessenger().getRequestId(), dhalgo);
-        req.setRecipients(v.getMembers());
+        req.setRecipients(recipients);
 
         services.getMessenger().send(req, v);
       }
@@ -1505,6 +1536,11 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
     if (viewCreator != null && !viewCreator.isShutdown()) {
       logger.debug("Shutting down ViewCreator");
       viewCreator.shutdown();
+      org.apache.geode.distributed.internal.membership.gms.interfaces.Locator locator =
+          services.getLocator();
+      if (locator != null) {
+        locator.setIsCoordinator(false);
+      }
       try {
         viewCreator.join(1000);
       } catch (InterruptedException e) {

http://git-wip-us.apache.org/repos/asf/geode/blob/3ee585c5/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/GMSEncrypt.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/GMSEncrypt.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/GMSEncrypt.java
index c7b1a26..f0461f2 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/GMSEncrypt.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/GMSEncrypt.java
@@ -30,6 +30,7 @@ import javax.crypto.spec.DHParameterSpec;
 import javax.crypto.spec.IvParameterSpec;
 import javax.crypto.spec.SecretKeySpec;
 
+import org.apache.geode.GemFireConfigException;
 import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
 import org.apache.geode.distributed.internal.membership.InternalDistributedMember.InternalDistributedMemberWrapper;
 import org.apache.geode.distributed.internal.membership.NetView;
@@ -106,7 +107,6 @@ public class GMSEncrypt implements Cloneable {
   protected synchronized void initClusterSecretKey() throws Exception {
     if (this.clusterEncryptor == null) {
       this.clusterEncryptor = new ClusterEncryptor(this);
-
     }
   }
 
@@ -579,16 +579,12 @@ public class GMSEncrypt implements Cloneable {
     }
 
     private Cipher getEncryptCipher(String dhSKAlgo) throws Exception {
-      try {
-        if (encrypt == null) {
-          synchronized (this) {
-            if (encrypt == null) {
-              encrypt = GMSEncrypt.getEncryptCipher(dhSKAlgo, secretBytes);
-            }
+      if (encrypt == null) {
+        synchronized (this) {
+          if (encrypt == null) {
+            encrypt = GMSEncrypt.getEncryptCipher(dhSKAlgo, secretBytes);
           }
         }
-      } catch (Exception ex) {
-        throw ex;
       }
       return encrypt;
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/3ee585c5/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/JGroupsMessenger.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
index 390824e..122e3ac 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
@@ -1413,7 +1413,7 @@ public class JGroupsMessenger implements Messenger {
   public void initClusterKey() {
     if (encrypt != null) {
       try {
-        logger.debug("Initializing cluster key");
+        logger.info("Initializing cluster key");
         encrypt.initClusterSecretKey();
       } catch (Exception e) {
         throw new RuntimeException("unable to create cluster key ", e);

http://git-wip-us.apache.org/repos/asf/geode/blob/3ee585c5/geode-core/src/test/java/org/apache/geode/distributed/LocatorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/LocatorDUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/LocatorDUnitTest.java
index 7ecca61..cbe5938 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/LocatorDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/LocatorDUnitTest.java
@@ -21,6 +21,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
 import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.MEMBER_TIMEOUT;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTHENTICATOR;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTH_INIT;
 import static org.apache.geode.distributed.ConfigurationProperties.SSL_CIPHERS;
@@ -81,6 +82,7 @@ import org.apache.geode.test.dunit.SerializableRunnable;
 import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.Wait;
 import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
+import org.apache.geode.test.dunit.standalone.DUnitLauncher;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.MembershipTest;
 import org.apache.geode.util.test.TestUtil;
@@ -412,18 +414,18 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
       getBlackboard().initBlackboard();
       AsyncInvocation<Boolean> async1 = loc1.invokeAsync("startLocator1", () -> {
         getBlackboard().signalGate("locator1");
-        getBlackboard().waitForGate("go", 10, TimeUnit.SECONDS);
+        getBlackboard().waitForGate("go", 60, TimeUnit.SECONDS);
         return startLocatorWithPortAndProperties(port1, properties);
       });
 
       AsyncInvocation<Boolean> async2 = loc2.invokeAsync("startLocator2", () -> {
         getBlackboard().signalGate("locator2");
-        getBlackboard().waitForGate("go", 10, TimeUnit.SECONDS);
+        getBlackboard().waitForGate("go", 60, TimeUnit.SECONDS);
         return startLocatorWithPortAndProperties(port2, properties);
       });
 
-      getBlackboard().waitForGate("locator1", 10, TimeUnit.SECONDS);
-      getBlackboard().waitForGate("locator2", 10, TimeUnit.SECONDS);
+      getBlackboard().waitForGate("locator1", 60, TimeUnit.SECONDS);
+      getBlackboard().waitForGate("locator2", 60, TimeUnit.SECONDS);
       getBlackboard().signalGate("go");
 
       async1.await();
@@ -1644,120 +1646,225 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
     vm2.invoke(() -> startLocatorAsync(new Object[] {port3, dsProps}));
 
     try {
-      try {
-        vm3.invoke(() -> {
-          DistributedSystem.connect(dsProps);
-          return true;
-        });
-        vm4.invoke(() -> {
-          DistributedSystem.connect(dsProps);
-          return true;
-        });
+      vm3.invoke(() -> {
+        DistributedSystem.connect(dsProps);
+        return true;
+      });
+      vm4.invoke(() -> {
+        DistributedSystem.connect(dsProps);
+        return true;
+      });
 
-        system = (InternalDistributedSystem) DistributedSystem.connect(dsProps);
+      system = (InternalDistributedSystem) DistributedSystem.connect(dsProps);
 
-        Awaitility.waitAtMost(10000, TimeUnit.MILLISECONDS).pollInterval(200, TimeUnit.MILLISECONDS)
-            .until(() -> {
-              try {
-                return system.getDM().getViewMembers().size() == 6;
-              } catch (Exception e) {
-                e.printStackTrace();
-                org.apache.geode.test.dunit.Assert.fail("unexpected exception", e);
-              }
-              return false; // NOTREACHED
-            });
+      Awaitility.waitAtMost(10000, TimeUnit.MILLISECONDS).pollInterval(200, TimeUnit.MILLISECONDS)
+          .until(() -> {
+            try {
+              return system.getDM().getViewMembers().size() == 6;
+            } catch (Exception e) {
+              e.printStackTrace();
+              org.apache.geode.test.dunit.Assert.fail("unexpected exception", e);
+            }
+            return false; // NOTREACHED
+          });
 
-        // three applications plus
-        assertEquals(6, system.getDM().getViewMembers().size());
+      // three applications plus
+      assertEquals(6, system.getDM().getViewMembers().size());
 
-        vm0.invoke(() -> stopLocator());
-        vm1.invoke(() -> stopLocator());
-        vm2.invoke(() -> stopLocator());
+      vm0.invoke(() -> stopLocator());
+      vm1.invoke(() -> stopLocator());
+      vm2.invoke(() -> stopLocator());
 
-        Awaitility.waitAtMost(10000, TimeUnit.MILLISECONDS).pollInterval(200, TimeUnit.MILLISECONDS)
-            .until(() -> {
-              try {
-                return system.getDM().getMembershipManager().getView().size() <= 3;
-              } catch (Exception e) {
-                e.printStackTrace();
-                org.apache.geode.test.dunit.Assert.fail("unexpected exception", e);
+      Awaitility.waitAtMost(10000, TimeUnit.MILLISECONDS).pollInterval(200, TimeUnit.MILLISECONDS)
+          .until(() -> {
+            try {
+              return system.getDM().getMembershipManager().getView().size() <= 3;
+            } catch (Exception e) {
+              e.printStackTrace();
+              org.apache.geode.test.dunit.Assert.fail("unexpected exception", e);
+            }
+            return false; // NOTREACHED
+          });
+
+      final String newLocators = host0 + "[" + port2 + "]," + host0 + "[" + port3 + "]";
+      dsProps.setProperty(LOCATORS, newLocators);
+
+      final InternalDistributedMember currentCoordinator =
+          GMSJoinLeaveTestHelper.getCurrentCoordinator();
+      DistributedMember vm3ID = vm3.invoke(() -> GMSJoinLeaveTestHelper
+          .getInternalDistributedSystem().getDM().getDistributionManagerId());
+      assertTrue("View is " + system.getDM().getMembershipManager().getView() + " and vm3's ID is "
+          + vm3ID, vm3.invoke(() -> GMSJoinLeaveTestHelper.isViewCreator()));
+
+      vm1.invoke(() -> startLocatorAsync(new Object[] {port2, dsProps}));
+      vm2.invoke(() -> startLocatorAsync(new Object[] {port3, dsProps}));
+
+      Awaitility.waitAtMost(30000, TimeUnit.MILLISECONDS).pollInterval(200, TimeUnit.MILLISECONDS)
+          .until(() -> {
+            try {
+              InternalDistributedMember c = GMSJoinLeaveTestHelper.getCurrentCoordinator();
+              if (c.equals(currentCoordinator)) {
+                // now locator should be new coordinator
+                return false;
               }
-              return false; // NOTREACHED
-            });
+              return system.getDM().getAllHostedLocators().size() == 2;
+            } catch (Exception e) {
+              e.printStackTrace();
+              org.apache.geode.test.dunit.Assert.fail("unexpected exception", e);
+            }
+            return false; // NOTREACHED
+          });
 
-        final String newLocators = host0 + "[" + port2 + "]," + host0 + "[" + port3 + "]";
-        dsProps.setProperty(LOCATORS, newLocators);
+      vm1.invoke("waitUntilLocatorBecomesCoordinator", () -> waitUntilLocatorBecomesCoordinator());
+      vm2.invoke("waitUntilLocatorBecomesCoordinator", () -> waitUntilLocatorBecomesCoordinator());
+      vm3.invoke("waitUntilLocatorBecomesCoordinator", () -> waitUntilLocatorBecomesCoordinator());
+      vm4.invoke("waitUntilLocatorBecomesCoordinator", () -> waitUntilLocatorBecomesCoordinator());
+
+      int netviewId = vm1.invoke("Checking ViewCreator", () -> GMSJoinLeaveTestHelper.getViewId());
+      assertEquals(netviewId,
+          (int) vm2.invoke("checking ViewID", () -> GMSJoinLeaveTestHelper.getViewId()));
+      assertEquals(netviewId,
+          (int) vm3.invoke("checking ViewID", () -> GMSJoinLeaveTestHelper.getViewId()));
+      assertEquals(netviewId,
+          (int) vm4.invoke("checking ViewID", () -> GMSJoinLeaveTestHelper.getViewId()));
+      assertFalse(vm4.invoke("Checking ViewCreator", () -> GMSJoinLeaveTestHelper.isViewCreator()));
+      // Given the start up order of servers, this server is the elder server
+      assertFalse(vm3.invoke("Checking ViewCreator", () -> GMSJoinLeaveTestHelper.isViewCreator()));
+      if (vm1.invoke(() -> GMSJoinLeaveTestHelper.isViewCreator())) {
+        assertFalse(
+            vm2.invoke("Checking ViewCreator", () -> GMSJoinLeaveTestHelper.isViewCreator()));
+      } else {
+        assertTrue(
+            vm2.invoke("Checking ViewCreator", () -> GMSJoinLeaveTestHelper.isViewCreator()));
+      }
 
-        final InternalDistributedMember currentCoordinator =
-            GMSJoinLeaveTestHelper.getCurrentCoordinator();
-        DistributedMember vm3ID = vm3.invoke(() -> GMSJoinLeaveTestHelper
-            .getInternalDistributedSystem().getDM().getDistributionManagerId());
-        assertTrue("View is " + system.getDM().getMembershipManager().getView()
-            + " and vm3's ID is " + vm3ID,
-            vm3.invoke(() -> GMSJoinLeaveTestHelper.isViewCreator()));
+    } finally {
+      system.disconnect();
+      vm3.invoke(() -> disconnectDistributedSystem());
+      vm4.invoke(() -> disconnectDistributedSystem());
+      vm2.invoke(() -> stopLocator());
+      vm1.invoke(() -> stopLocator());
+    }
+  }
 
-        vm1.invoke(() -> startLocatorAsync(new Object[] {port2, dsProps}));
-        vm2.invoke(() -> startLocatorAsync(new Object[] {port3, dsProps}));
+  @Test
+  public void testMultipleLocatorsRestartingAtSameTimeWithMissingServers() throws Exception {
+    disconnectAllFromDS();
+    IgnoredException.addIgnoredException("ForcedDisconnectException");
+    IgnoredException.addIgnoredException("Possible loss of quorum");
+    Host host = Host.getHost(0);
+    VM vm0 = host.getVM(0);
+    VM vm1 = host.getVM(1);
+    VM vm2 = host.getVM(2);
+    VM vm3 = host.getVM(3);
+    VM vm4 = host.getVM(4);
 
-        Awaitility.waitAtMost(30000, TimeUnit.MILLISECONDS).pollInterval(200, TimeUnit.MILLISECONDS)
+    int[] freeTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(3);
+    this.port1 = freeTCPPorts[0];
+    this.port2 = freeTCPPorts[1];
+    int port3 = freeTCPPorts[2];
+    DistributedTestUtils.deleteLocatorStateFile(port1, port2, port3);
+    final String host0 = NetworkUtils.getServerHostName(host);
+    final String locators =
+        host0 + "[" + port1 + "]," + host0 + "[" + port2 + "]," + host0 + "[" + port3 + "]";
+
+    final Properties dsProps = new Properties();
+    dsProps.setProperty(LOCATORS, locators);
+    dsProps.setProperty(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel());
+    dsProps.setProperty(DISABLE_AUTO_RECONNECT, "true");
+    dsProps.setProperty(MCAST_PORT, "0");
+
+    addDSProps(dsProps);
+    vm0.invoke(() -> startLocatorAsync(new Object[] {port1, dsProps}));
+    vm1.invoke(() -> startLocatorAsync(new Object[] {port2, dsProps}));
+    vm2.invoke(() -> startLocatorAsync(new Object[] {port3, dsProps}));
+
+    try {
+      vm3.invoke(() -> {
+        DistributedSystem.connect(dsProps);
+        return true;
+      });
+      vm4.invoke(() -> {
+        DistributedSystem.connect(dsProps);
+
+        Awaitility.waitAtMost(10000, TimeUnit.MILLISECONDS).pollInterval(200, TimeUnit.MILLISECONDS)
             .until(() -> {
               try {
-                InternalDistributedMember c = GMSJoinLeaveTestHelper.getCurrentCoordinator();
-                if (c.equals(currentCoordinator)) {
-                  // now locator should be new coordinator
-                  return false;
-                }
-                return system.getDM().getAllHostedLocators().size() == 2;
+                return InternalDistributedSystem.getConnectedInstance().getDM().getViewMembers()
+                    .size() == 5;
               } catch (Exception e) {
                 e.printStackTrace();
                 org.apache.geode.test.dunit.Assert.fail("unexpected exception", e);
               }
               return false; // NOTREACHED
             });
+        return true;
+      });
 
-        vm1.invoke("waitUntilLocatorBecomesCoordinator",
-            () -> waitUntilLocatorBecomesCoordinator());
-        vm2.invoke("waitUntilLocatorBecomesCoordinator",
-            () -> waitUntilLocatorBecomesCoordinator());
-        vm3.invoke("waitUntilLocatorBecomesCoordinator",
-            () -> waitUntilLocatorBecomesCoordinator());
-        vm4.invoke("waitUntilLocatorBecomesCoordinator",
-            () -> waitUntilLocatorBecomesCoordinator());
-
-        int netviewId =
-            vm1.invoke("Checking ViewCreator", () -> GMSJoinLeaveTestHelper.getViewId());
-        assertEquals(netviewId,
-            (int) vm2.invoke("checking ViewID", () -> GMSJoinLeaveTestHelper.getViewId()));
-        assertEquals(netviewId,
-            (int) vm3.invoke("checking ViewID", () -> GMSJoinLeaveTestHelper.getViewId()));
-        assertEquals(netviewId,
-            (int) vm4.invoke("checking ViewID", () -> GMSJoinLeaveTestHelper.getViewId()));
-        assertFalse(
-            vm4.invoke("Checking ViewCreator", () -> GMSJoinLeaveTestHelper.isViewCreator()));
-        // Given the start up order of servers, this server is the elder server
-        assertFalse(
-            vm3.invoke("Checking ViewCreator", () -> GMSJoinLeaveTestHelper.isViewCreator()));
-        if (vm1.invoke(() -> GMSJoinLeaveTestHelper.isViewCreator())) {
-          assertFalse(
-              vm2.invoke("Checking ViewCreator", () -> GMSJoinLeaveTestHelper.isViewCreator()));
-        } else {
-          assertTrue(
-              vm2.invoke("Checking ViewCreator", () -> GMSJoinLeaveTestHelper.isViewCreator()));
+      vm0.invoke(() -> forceDisconnect());
+      vm1.invoke(() -> forceDisconnect());
+      vm2.invoke(() -> forceDisconnect());
+
+      SerializableRunnable waitForDisconnect = new SerializableRunnable("waitForDisconnect") {
+        public void run() {
+          Awaitility.waitAtMost(10000, TimeUnit.MILLISECONDS)
+              .pollInterval(200, TimeUnit.MILLISECONDS).until(() -> {
+                try {
+                  return InternalDistributedSystem.getConnectedInstance() == null;
+                } catch (Exception e) {
+                  org.apache.geode.test.dunit.Assert.fail("unexpected exception", e);
+                }
+                return false; // NOTREACHED
+              });
         }
+      };
+      vm0.invoke(() -> waitForDisconnect);
+      vm1.invoke(() -> waitForDisconnect);
+      vm2.invoke(() -> waitForDisconnect);
+      disconnectAllFromDS();
 
-      } finally {
-        system.disconnect();
-        vm3.invoke(() -> disconnectDistributedSystem());
-        vm4.invoke(() -> disconnectDistributedSystem());
-        vm2.invoke(() -> stopLocator());
-        vm1.invoke(() -> stopLocator());
+
+      final String newLocators = host0 + "[" + port2 + "]," + host0 + "[" + port3 + "]";
+      dsProps.setProperty(LOCATORS, newLocators);
+
+      getBlackboard().initBlackboard();
+      AsyncInvocation async1 = vm1.invokeAsync(() -> {
+        getBlackboard().signalGate("vm1ready");
+        getBlackboard().waitForGate("readyToConnect", 30, TimeUnit.SECONDS);
+        System.out.println("vm1 is ready to connect");
+        startLocatorAsync(new Object[] {port2, dsProps});
+      });
+      AsyncInvocation async2 = vm2.invokeAsync(() -> {
+        getBlackboard().signalGate("vm2ready");
+        getBlackboard().waitForGate("readyToConnect", 30, TimeUnit.SECONDS);
+        System.out.println("vm2 is ready to connect");
+        startLocatorAsync(new Object[] {port3, dsProps});
+      });
+      getBlackboard().waitForGate("vm1ready", 30, TimeUnit.SECONDS);
+      getBlackboard().waitForGate("vm2ready", 30, TimeUnit.SECONDS);
+      getBlackboard().signalGate("readyToConnect");
+      async1.join();
+      async2.join();
+
+      vm1.invoke("waitUntilLocatorBecomesCoordinator", () -> waitUntilLocatorBecomesCoordinator());
+      vm2.invoke("waitUntilLocatorBecomesCoordinator", () -> waitUntilLocatorBecomesCoordinator());
+
+      if (vm1.invoke(() -> GMSJoinLeaveTestHelper.isViewCreator())) {
+        assertFalse(
+            vm2.invoke("Checking ViewCreator", () -> GMSJoinLeaveTestHelper.isViewCreator()));
+      } else {
+        assertTrue(
+            vm2.invoke("Checking ViewCreator", () -> GMSJoinLeaveTestHelper.isViewCreator()));
       }
+
     } finally {
+      vm2.invoke(() -> stopLocator());
+      vm1.invoke(() -> stopLocator());
     }
   }
 
   private void waitUntilLocatorBecomesCoordinator() {
-    Awaitility.waitAtMost(15000, TimeUnit.MILLISECONDS).pollInterval(200, TimeUnit.MILLISECONDS)
+    Awaitility.waitAtMost(30000, TimeUnit.MILLISECONDS).pollInterval(1000, TimeUnit.MILLISECONDS)
         .until(() -> {
           try {
             InternalDistributedMember c = GMSJoinLeaveTestHelper.getCurrentCoordinator();
@@ -1781,8 +1888,10 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
 
   private void startLocatorAsync(Object[] args) {
     File logFile = new File("");
+    Properties properties = (Properties) args[1];
+    properties.put(NAME, "vm" + VM.getCurrentVMNum());
     try {
-      Locator.startLocatorAndDS((int) args[0], logFile, (Properties) args[1]);
+      Locator.startLocatorAndDS((int) args[0], logFile, properties);
     } catch (IOException ex) {
       org.apache.geode.test.dunit.Assert.fail("While starting process on port " + args[0], ex);
     }
@@ -1879,6 +1988,7 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
     p.setProperty(LOCATORS, Host.getHost(0).getHostName() + "[" + port1 + "]");
     p.setProperty(MCAST_PORT, "0");
     p.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
+    p.setProperty(LOG_LEVEL, DUnitLauncher.logLevel);
     addDSProps(p);
     if (stateFile.exists()) {
       stateFile.delete();
@@ -1948,6 +2058,10 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
     }
   }
 
+  protected void forceDisconnect() {
+    DistributedTestUtils.crashDistributedSystem(InternalDistributedSystem.getConnectedInstance());
+  }
+
   private void startSBLocator(final int port) {
     File logFile = new File("");
     try {

http://git-wip-us.apache.org/repos/asf/geode/blob/3ee585c5/geode-core/src/test/java/org/apache/geode/distributed/LocatorUDPSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/LocatorUDPSecurityDUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/LocatorUDPSecurityDUnitTest.java
index df1d8d1..89d2507 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/LocatorUDPSecurityDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/LocatorUDPSecurityDUnitTest.java
@@ -30,6 +30,7 @@ import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
 import org.apache.geode.test.junit.categories.MembershipTest;
 import org.junit.Assert;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -45,6 +46,13 @@ public class LocatorUDPSecurityDUnitTest extends LocatorDUnitTest {
     p.setProperty(SECURITY_UDP_DHALGO, "AES:128");
   }
 
+  @Override
+  @Test
+  @Ignore // GEODE-3094
+  public void testMultipleLocatorsRestartingAtSameTimeWithMissingServers() throws Exception {
+    super.testMultipleLocatorsRestartingAtSameTimeWithMissingServers();
+  }
+
   @Test
   public void testLocatorWithUDPSecurityButServer() throws Exception {
     disconnectAllFromDS();

http://git-wip-us.apache.org/repos/asf/geode/blob/3ee585c5/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveTestHelper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveTestHelper.java b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveTestHelper.java
index 19cee06..8c953f7 100755
--- a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveTestHelper.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeaveTestHelper.java
@@ -34,12 +34,13 @@ public class GMSJoinLeaveTestHelper {
   public static boolean isViewCreator() {
     GMSJoinLeave gmsJoinLeave = getGmsJoinLeave();
     if (gmsJoinLeave != null) {
-      GMSJoinLeave.ViewCreator viewCreator = gmsJoinLeave.getViewCreator();
-      if (viewCreator != null && !viewCreator.isShutdown()) {
-        return true;
-      } else {
-        return false;
-      }
+      return gmsJoinLeave.getView().getCreator().equals(gmsJoinLeave.getMemberID());
+      // GMSJoinLeave.ViewCreator viewCreator = gmsJoinLeave.getViewCreator();
+      // if (viewCreator != null && !viewCreator.isShutdown()) {
+      // return true;
+      // } else {
+      // return false;
+      // }
     }
     throw new RuntimeException(
         "This should not have happened. There should be a JoinLeave for every DS");
@@ -88,6 +89,9 @@ public class GMSJoinLeaveTestHelper {
     InternalDistributedSystem distributedSystem = InternalDistributedSystem.getAnyInstance();
     if (distributedSystem == null) {
       Locator locator = Locator.getLocator();
+      if (locator == null) {
+        return null;
+      }
       return (InternalDistributedSystem) locator.getDistributedSystem();
     } else {
       return distributedSystem;

http://git-wip-us.apache.org/repos/asf/geode/blob/3ee585c5/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
index 7f64c67..78d508b 100755
--- a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
@@ -17,7 +17,6 @@ package org.apache.geode.distributed.internal.membership.gms.messenger;
 import static org.mockito.Mockito.*;
 
 import org.apache.geode.distributed.ConfigurationProperties;
-import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.distributed.internal.DistributionConfigImpl;
 import org.apache.geode.distributed.internal.DistributionManager;
 import org.apache.geode.distributed.internal.membership.InternalDistributedMember;


[35/46] geode git commit: GEODE-2995: Handle stream of ProtoBuf encoded messages

Posted by zh...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.operations.OperationHandler
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.operations.OperationHandler b/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.operations.OperationHandler
new file mode 100644
index 0000000..fa7c3c6
--- /dev/null
+++ b/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.operations.OperationHandler
@@ -0,0 +1 @@
+org.apache.geode.protocol.operations.protobuf.GetRequestOperationHandler
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.serialization.TypeCodec
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.serialization.TypeCodec b/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.serialization.TypeCodec
new file mode 100644
index 0000000..1b7b333
--- /dev/null
+++ b/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.serialization.TypeCodec
@@ -0,0 +1,10 @@
+org.apache.geode.serialization.codec.BinaryCodec
+org.apache.geode.serialization.codec.BooleanCodec
+org.apache.geode.serialization.codec.ByteCodec
+org.apache.geode.serialization.codec.DoubleCodec
+org.apache.geode.serialization.codec.FloatCodec
+org.apache.geode.serialization.codec.IntCodec
+org.apache.geode.serialization.codec.JSONCodec
+org.apache.geode.serialization.codec.LongCodec
+org.apache.geode.serialization.codec.ShortCodec
+org.apache.geode.serialization.codec.StringCodec

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java
new file mode 100644
index 0000000..e86e908
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java
@@ -0,0 +1,121 @@
+/*
+ * 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.client.protocol;
+
+import com.google.protobuf.ByteString;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.Region;
+import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
+import org.apache.geode.protocol.handler.ProtobufStreamProcessor;
+import org.apache.geode.protocol.operations.registry.exception.OperationHandlerAlreadyRegisteredException;
+import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException;
+import org.apache.geode.protocol.protobuf.BasicTypes;
+import org.apache.geode.protocol.protobuf.ClientProtocol;
+import org.apache.geode.protocol.protobuf.RegionAPI;
+import org.apache.geode.serialization.codec.StringCodec;
+import org.apache.geode.serialization.protobuf.translation.EncodingTypeTranslator;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.SerializationCodecRegistry;
+import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+import org.apache.geode.test.dunit.Assert;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+@Category(UnitTest.class)
+public class IntegrationTest {
+
+  public static final String TEST_KEY = "my key";
+  public static final String TEST_VALUE = "my value";
+  public static final String TEST_REGION = "test region";
+  private StringCodec stringCodec;
+  private Cache cacheStub;
+
+  @Before
+  public void setup() throws CodecAlreadyRegisteredForTypeException,
+      UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
+    SerializationCodecRegistry serializationCodecRegistry = new SerializationCodecRegistry();
+    stringCodec = (StringCodec) serializationCodecRegistry.getCodecForType(
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.STRING));
+    cacheStub = getCacheStub();
+  }
+
+  @Test
+  public void testFullRequestToCache()
+      throws OperationHandlerAlreadyRegisteredException, CodecAlreadyRegisteredForTypeException,
+      UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException,
+      OperationHandlerNotRegisteredException, IOException, InvalidProtocolMessageException {
+
+    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+
+    ProtobufStreamProcessor streamProcessor = new ProtobufStreamProcessor();
+    streamProcessor.processOneMessage(getInputStream(getRequest(stringCodec)), outputStream,
+        cacheStub);
+
+    RegionAPI.GetResponse getResponse = getGetResponse(outputStream);
+
+    Assert.assertNotNull(getResponse);
+    Assert.assertEquals(BasicTypes.EncodingType.STRING, getResponse.getResult().getEncodingType());
+    String actualValue = stringCodec.decode(getResponse.getResult().getValue().toByteArray());
+    Assert.assertEquals(TEST_VALUE, actualValue);
+  }
+
+  private Cache getCacheStub() {
+    Region regionStub = mock(Region.class);
+    when(regionStub.get(TEST_KEY)).thenReturn(TEST_VALUE);
+
+    Cache cacheStub = mock(Cache.class);
+    when(cacheStub.getRegion(TEST_REGION)).thenReturn(regionStub);
+    return cacheStub;
+  }
+
+  private RegionAPI.GetResponse getGetResponse(ByteArrayOutputStream outputStream)
+      throws IOException {
+    ByteArrayInputStream helperInputStream = new ByteArrayInputStream(outputStream.toByteArray());
+    ClientProtocol.Message responseMessage =
+        ClientProtocol.Message.parseDelimitedFrom(helperInputStream);
+    ClientProtocol.Response response = responseMessage.getResponse();
+    return response.getGetResponse();
+  }
+
+  private ByteArrayInputStream getInputStream(ClientProtocol.Message request) throws IOException {
+    ByteArrayOutputStream helperOutputStream = new ByteArrayOutputStream();
+    request.writeDelimitedTo(helperOutputStream);
+    return new ByteArrayInputStream(helperOutputStream.toByteArray());
+  }
+
+  private ClientProtocol.Message getRequest(StringCodec stringCodec) {
+    RegionAPI.GetRequest.Builder getRequestBuilder = RegionAPI.GetRequest.newBuilder();
+    getRequestBuilder.setRegionName(TEST_REGION)
+        .setKey(BasicTypes.EncodedValue.newBuilder().setEncodingType(BasicTypes.EncodingType.STRING)
+            .setValue(ByteString.copyFrom(stringCodec.encode(TEST_KEY))));
+    ClientProtocol.Request request =
+        ClientProtocol.Request.newBuilder().setGetRequest(getRequestBuilder).build();
+    ClientProtocol.Message requestMessage = ClientProtocol.Message.newBuilder()
+        .setMessageHeader(ClientProtocol.MessageHeader.newBuilder()).setRequest(request).build();
+
+    return requestMessage;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/test/java/org/apache/geode/client/protocol/MessageUtil.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/MessageUtil.java b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/MessageUtil.java
new file mode 100644
index 0000000..c830b01
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/MessageUtil.java
@@ -0,0 +1,41 @@
+/*
+ * 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.client.protocol;
+
+import org.apache.geode.protocol.protobuf.ClientProtocol;
+import org.apache.geode.protocol.protobuf.RegionAPI;
+
+public class MessageUtil {
+  public static ClientProtocol.Message createGetRequestMessage() {
+    ClientProtocol.Message.Builder messageBuilder = ClientProtocol.Message.newBuilder();
+    messageBuilder.setMessageHeader(getMessageHeaderBuilder());
+    ClientProtocol.Request.Builder requestBuilder = getRequestBuilder();
+    requestBuilder.setGetRequest(getGetRequestBuilder());
+    messageBuilder.setRequest(requestBuilder);
+    return messageBuilder.build();
+  }
+
+  private static ClientProtocol.Request.Builder getRequestBuilder() {
+    return ClientProtocol.Request.newBuilder();
+  }
+
+  private static RegionAPI.GetRequest.Builder getGetRequestBuilder() {
+    return RegionAPI.GetRequest.newBuilder();
+  }
+
+  private static ClientProtocol.MessageHeader.Builder getMessageHeaderBuilder() {
+    return ClientProtocol.MessageHeader.newBuilder();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsHandler.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsHandler.java b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsHandler.java
new file mode 100644
index 0000000..793dace
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsHandler.java
@@ -0,0 +1,21 @@
+/*
+ * 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.client.protocol;
+
+import org.apache.geode.serialization.registry.SerializationCodecRegistry;
+
+public interface OpsHandler<Req, Resp> {
+  Resp process(SerializationCodecRegistry serializationCodecRegistry, Req request);
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsProcessorTest.java b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsProcessorTest.java
new file mode 100644
index 0000000..1ec7a02
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsProcessorTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.client.protocol;
+
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.RegionService;
+import org.apache.geode.protocol.OpsProcessor;
+import org.apache.geode.protocol.operations.OperationHandler;
+import org.apache.geode.protocol.operations.ProtobufRequestOperationParser;
+import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry;
+import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException;
+import org.apache.geode.protocol.protobuf.ClientProtocol;
+import org.apache.geode.protocol.protobuf.RegionAPI;
+import org.apache.geode.serialization.SerializationService;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(UnitTest.class)
+public class OpsProcessorTest {
+  @Test
+  public void testOpsProcessor() throws CodecNotRegisteredForTypeException,
+      OperationHandlerNotRegisteredException, UnsupportedEncodingTypeException {
+    OperationsHandlerRegistry opsHandlerRegistryStub = mock(OperationsHandlerRegistry.class);
+    OperationHandler operationHandlerStub = mock(OperationHandler.class);
+    SerializationService serializationServiceStub = mock(SerializationService.class);
+    Cache dummyCache = mock(Cache.class);
+    int operationID = ClientProtocol.Request.RequestAPICase.GETREQUEST.getNumber();
+
+    ClientProtocol.Request messageRequest = ClientProtocol.Request.newBuilder()
+        .setGetRequest(RegionAPI.GetRequest.newBuilder()).build();
+
+    RegionAPI.GetResponse expectedResponse = RegionAPI.GetResponse.newBuilder().build();
+
+    when(opsHandlerRegistryStub.getOperationHandlerForOperationId(operationID))
+        .thenReturn(operationHandlerStub);
+    when(operationHandlerStub.process(serializationServiceStub,
+        ProtobufRequestOperationParser.getRequestForOperationTypeID(messageRequest), dummyCache))
+            .thenReturn(expectedResponse);
+
+    OpsProcessor processor = new OpsProcessor(opsHandlerRegistryStub, serializationServiceStub);
+    ClientProtocol.Response response = processor.process(messageRequest, dummyCache);
+    Assert.assertEquals(expectedResponse, response.getGetResponse());
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/test/java/org/apache/geode/protocol/handler/ProtobufProtocolHandlerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/handler/ProtobufProtocolHandlerJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/handler/ProtobufProtocolHandlerJUnitTest.java
new file mode 100644
index 0000000..21c3107
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/handler/ProtobufProtocolHandlerJUnitTest.java
@@ -0,0 +1,88 @@
+/*
+ * 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.protocol.handler;
+
+import org.apache.geode.client.protocol.MessageUtil;
+import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
+import org.apache.geode.protocol.handler.ProtocolHandler;
+import org.apache.geode.protocol.handler.protobuf.ProtobufProtocolHandler;
+import org.apache.geode.protocol.protobuf.ClientProtocol;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ServiceLoader;
+
+@Category(UnitTest.class)
+public class ProtobufProtocolHandlerJUnitTest {
+  private ProtocolHandler<ClientProtocol.Message> protocolHandler;
+
+  @Before
+  public void startup() {
+    ServiceLoader<ProtocolHandler> serviceLoader = ServiceLoader.load(ProtocolHandler.class);
+    for (ProtocolHandler protocolHandler : serviceLoader) {
+      if (protocolHandler instanceof ProtobufProtocolHandler) {
+        this.protocolHandler = protocolHandler;
+      }
+    }
+  }
+
+  @Test
+  public void testDeserializeByteArrayToMessage()
+      throws IOException, InvalidProtocolMessageException {
+    ClientProtocol.Message expectedRequestMessage = MessageUtil.createGetRequestMessage();
+
+    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+
+    expectedRequestMessage.writeDelimitedTo(byteArrayOutputStream);
+    InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
+
+    ClientProtocol.Message actualMessage = protocolHandler.deserialize(inputStream);
+    Assert.assertEquals(expectedRequestMessage, actualMessage);
+  }
+
+  @Test
+  public void testDeserializeInvalidByteThrowsException() throws IOException {
+    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+    byteArrayOutputStream.write("Some incorrect byte array".getBytes());
+    InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
+
+    boolean caughtException = false;
+    try {
+      protocolHandler.deserialize(inputStream);
+    } catch (InvalidProtocolMessageException e) {
+      caughtException = true;
+    }
+    Assert.assertTrue(caughtException);
+  }
+
+  @Test
+  public void testSerializeMessageToByteArray() throws IOException {
+    ClientProtocol.Message message = MessageUtil.createGetRequestMessage();
+    ByteArrayOutputStream expectedByteArrayOutputStream = new ByteArrayOutputStream();
+    message.writeDelimitedTo(expectedByteArrayOutputStream);
+    byte[] expectedByteArray = expectedByteArrayOutputStream.toByteArray();
+
+    ByteArrayOutputStream actualByteArrayOutputStream = new ByteArrayOutputStream();
+    protocolHandler.serialize(message, actualByteArrayOutputStream);
+    Assert.assertArrayEquals(expectedByteArray, actualByteArrayOutputStream.toByteArray());
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandlerTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandlerTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandlerTest.java
new file mode 100644
index 0000000..359db7d
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandlerTest.java
@@ -0,0 +1,95 @@
+/*
+ * 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.protocol.operations.protobuf;
+
+import com.google.protobuf.ByteString;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionService;
+import org.apache.geode.protocol.protobuf.BasicTypes;
+import org.apache.geode.protocol.protobuf.RegionAPI;
+import org.apache.geode.serialization.SerializationService;
+import org.apache.geode.serialization.codec.StringCodec;
+import org.apache.geode.serialization.protobuf.translation.EncodingTypeTranslator;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.SerializationCodecRegistry;
+import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+import org.apache.geode.test.dunit.Assert;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.nio.charset.Charset;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@Category(UnitTest.class)
+public class GetRequestOperationHandlerTest {
+  public static final String TEST_KEY = "my key";
+  public static final String TEST_VALUE = "my value";
+  public static final String TEST_REGION = "test region";
+  public Cache cacheStub;
+  public SerializationService serializationServiceStub;
+
+  @Before
+  public void setUp() throws Exception {
+    serializationServiceStub = mock(SerializationService.class);
+    when(serializationServiceStub.decode(BasicTypes.EncodingType.STRING,
+        TEST_KEY.getBytes(Charset.forName("UTF-8")))).thenReturn(TEST_KEY);
+    when(serializationServiceStub.encode(BasicTypes.EncodingType.STRING, TEST_VALUE))
+        .thenReturn(TEST_VALUE.getBytes(Charset.forName("UTF-8")));
+
+    Region regionStub = mock(Region.class);
+    when(regionStub.get(TEST_KEY)).thenReturn(TEST_VALUE);
+
+    cacheStub = mock(Cache.class);
+    when(cacheStub.getRegion(TEST_REGION)).thenReturn(regionStub);
+  }
+
+  @Test
+  public void processReturnsTheEncodedValueFromTheRegion() throws UnsupportedEncodingTypeException,
+      CodecNotRegisteredForTypeException, CodecAlreadyRegisteredForTypeException {
+    GetRequestOperationHandler operationHandler = new GetRequestOperationHandler();
+
+    RegionAPI.GetResponse response =
+        operationHandler.process(serializationServiceStub, makeGetRequest(), cacheStub);
+
+    Assert.assertEquals(BasicTypes.EncodingType.STRING, response.getResult().getEncodingType());
+    String actualValue = getStringCodec().decode(response.getResult().getValue().toByteArray());
+    Assert.assertEquals(TEST_VALUE, actualValue);
+  }
+
+  private RegionAPI.GetRequest makeGetRequest() throws CodecNotRegisteredForTypeException,
+      UnsupportedEncodingTypeException, CodecAlreadyRegisteredForTypeException {
+    StringCodec stringCodec = getStringCodec();
+    RegionAPI.GetRequest.Builder getRequestBuilder = RegionAPI.GetRequest.newBuilder();
+    getRequestBuilder.setRegionName(TEST_REGION)
+        .setKey(BasicTypes.EncodedValue.newBuilder().setEncodingType(BasicTypes.EncodingType.STRING)
+            .setValue(ByteString.copyFrom(stringCodec.encode(TEST_KEY))));
+
+    return getRequestBuilder.build();
+  }
+
+  private StringCodec getStringCodec() throws CodecAlreadyRegisteredForTypeException,
+      CodecNotRegisteredForTypeException, UnsupportedEncodingTypeException {
+    SerializationCodecRegistry serializationCodecRegistry = new SerializationCodecRegistry();
+    return (StringCodec) serializationCodecRegistry.getCodecForType(
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.STRING));
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/registry/OperationsHandlerRegistryJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/registry/OperationsHandlerRegistryJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/registry/OperationsHandlerRegistryJUnitTest.java
new file mode 100644
index 0000000..612e6a7
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/registry/OperationsHandlerRegistryJUnitTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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.protocol.operations.registry;
+
+import static io.codearte.catchexception.shade.mockito.Mockito.mock;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.geode.protocol.operations.OperationHandler;
+import org.apache.geode.protocol.operations.registry.exception.OperationHandlerAlreadyRegisteredException;
+import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(UnitTest.class)
+public class OperationsHandlerRegistryJUnitTest {
+  public static final int DUMMY_OPERATION_CODE = 999;
+  private OperationsHandlerRegistry operationsHandlerRegistry;
+
+  @Before
+  public void setup() throws OperationHandlerAlreadyRegisteredException {
+    operationsHandlerRegistry = new OperationsHandlerRegistry();
+  }
+
+  @Test
+  public void testAddOperationsHandlerForOperationType()
+      throws OperationHandlerAlreadyRegisteredException {
+    int initialHandlerCount = operationsHandlerRegistry.getRegisteredOperationHandlersCount();
+    operationsHandlerRegistry.registerOperationHandlerForOperationId(DUMMY_OPERATION_CODE,
+        mock(OperationHandler.class));
+    assertEquals(initialHandlerCount + 1,
+        operationsHandlerRegistry.getRegisteredOperationHandlersCount());
+  }
+
+  @Test
+  public void testAddingDuplicateOperationsHandlerForOperationType_ThrowsException()
+      throws OperationHandlerAlreadyRegisteredException, OperationHandlerNotRegisteredException {
+    OperationHandler expectedOperationHandler = mock(OperationHandler.class);
+    OperationHandler unexpectedOperationHandler = mock(OperationHandler.class);
+    operationsHandlerRegistry.registerOperationHandlerForOperationId(DUMMY_OPERATION_CODE,
+        expectedOperationHandler);
+    int initialHandlerCount = operationsHandlerRegistry.getRegisteredOperationHandlersCount();
+    boolean exceptionCaught = false;
+    try {
+      operationsHandlerRegistry.registerOperationHandlerForOperationId(DUMMY_OPERATION_CODE,
+          unexpectedOperationHandler);
+    } catch (OperationHandlerAlreadyRegisteredException e) {
+      exceptionCaught = true;
+    }
+    assertTrue(exceptionCaught);
+    assertEquals(initialHandlerCount,
+        operationsHandlerRegistry.getRegisteredOperationHandlersCount());
+    assertSame(expectedOperationHandler,
+        operationsHandlerRegistry.getOperationHandlerForOperationId(DUMMY_OPERATION_CODE));
+  }
+
+  @Test
+  public void testGetOperationsHandlerForOperationType()
+      throws OperationHandlerAlreadyRegisteredException, OperationHandlerNotRegisteredException {
+    OperationHandler expectedOperationHandler = mock(OperationHandler.class);
+
+    operationsHandlerRegistry.registerOperationHandlerForOperationId(DUMMY_OPERATION_CODE,
+        expectedOperationHandler);
+    OperationHandler operationHandler =
+        operationsHandlerRegistry.getOperationHandlerForOperationId(DUMMY_OPERATION_CODE);
+    assertSame(expectedOperationHandler, operationHandler);
+  }
+
+  @Test
+  public void testGetOperationsHandlerForMissingOperationType_ThrowsException() {
+    boolean exceptionCaught = false;
+    try {
+      operationsHandlerRegistry.getOperationHandlerForOperationId(DUMMY_OPERATION_CODE);
+    } catch (OperationHandlerNotRegisteredException e) {
+      exceptionCaught = true;
+    }
+    assertTrue(exceptionCaught);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceImplTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceImplTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceImplTest.java
new file mode 100644
index 0000000..a4c0a14
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceImplTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.serialization;
+
+import org.apache.geode.protocol.protobuf.BasicTypes;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(UnitTest.class)
+public class ProtobufSerializationServiceImplTest {
+
+  public static final String PAYLOAD = "my value";
+
+  @Test
+  public void valuesPreservedByEncodingThenDecoding() throws CodecAlreadyRegisteredForTypeException,
+      UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
+    ProtobufSerializationService protobufSerializationService = new ProtobufSerializationService();
+
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.STRING, "testString");
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.FLOAT, (float) 34.23);
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.DOUBLE, 34.23);
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.INT, 45);
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.SHORT, (short) 45);
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BYTE, (byte) 45);
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.LONG, (long) 45);
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BOOLEAN, false);
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BOOLEAN, true);
+    testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BINARY,
+        "testString".getBytes());
+    // TODO: Test JSON conversion
+  }
+
+  private void testEncodeDecode(ProtobufSerializationService service,
+      BasicTypes.EncodingType encodingType, Object data)
+      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
+    byte[] encodedValue = service.encode(encodingType, data);
+    Object decdoedValue = service.decode(encodingType, encodedValue);
+    Assert.assertEquals(data, decdoedValue);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/StringCodecJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/StringCodecJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/StringCodecJUnitTest.java
new file mode 100644
index 0000000..8cd6029
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/StringCodecJUnitTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.serialization.codec;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.nio.charset.Charset;
+
+@Category(UnitTest.class)
+public class StringCodecJUnitTest {
+  private static final Charset UTF8 = Charset.forName("UTF-8");
+  private static final Charset UTF16 = Charset.forName("UTF-16");
+  private String testString = "Test String";
+
+  private StringCodec stringCodec;
+
+  @Before
+  public void startup() {
+    stringCodec = new StringCodec();
+  }
+
+  @Test
+  public void testStringEncoding() {
+    assertArrayEquals(testString.getBytes(UTF8), stringCodec.encode(testString));
+  }
+
+  @Test
+  public void testStringIncompatibleEncoding() {
+    byte[] expectedEncodedString = stringCodec.encode(testString);
+    byte[] incorrectEncodedString = testString.getBytes(UTF16);
+    assertNotEquals(expectedEncodedString.length, incorrectEncodedString.length);
+  }
+
+  @Test
+  public void testStringDecodingWithIncorrectEncodedString() {
+    byte[] encodedString = testString.getBytes(UTF16);
+    assertNotEquals(testString, stringCodec.decode(encodedString));
+  }
+
+  @Test
+  public void testStringDecoding() {
+    byte[] encodedString = testString.getBytes(UTF8);
+    assertEquals(testString, stringCodec.decode(encodedString));
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/test/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslatorJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslatorJUnitTest.java
new file mode 100644
index 0000000..1af710c
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslatorJUnitTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.serialization.protobuf.translation;
+
+import static org.junit.Assert.assertSame;
+
+import org.apache.geode.protocol.protobuf.BasicTypes;
+import org.apache.geode.serialization.SerializationType;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(UnitTest.class)
+public class EncodingTypeToSerializationTypeTranslatorJUnitTest {
+
+  @Test
+  public void testTranslateEncodingTypes() throws UnsupportedEncodingTypeException {
+    assertSame(SerializationType.INT,
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.INT));
+    assertSame(SerializationType.LONG,
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.LONG));
+    assertSame(SerializationType.SHORT,
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.SHORT));
+    assertSame(SerializationType.BYTE,
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.BYTE));
+    assertSame(SerializationType.BOOLEAN, EncodingTypeTranslator
+        .getSerializationTypeForEncodingType(BasicTypes.EncodingType.BOOLEAN));
+    assertSame(SerializationType.BINARY,
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.BINARY));
+    assertSame(SerializationType.FLOAT,
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.FLOAT));
+    assertSame(SerializationType.DOUBLE,
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.DOUBLE));
+    assertSame(SerializationType.STRING,
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.STRING));
+    assertSame(SerializationType.JSON,
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.JSON));
+  }
+
+  @Test(expected = UnsupportedEncodingTypeException.class)
+  public void testTranslateInvalidEncoding_throwsException()
+      throws UnsupportedEncodingTypeException {
+    EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.INVALID);
+  }
+
+  @Test
+  public void testAllEncodingTypeTranslations() {
+    for (BasicTypes.EncodingType encodingType : BasicTypes.EncodingType.values()) {
+      if (!(encodingType.equals(BasicTypes.EncodingType.UNRECOGNIZED)
+          || encodingType.equals(BasicTypes.EncodingType.INVALID))) {
+        try {
+          EncodingTypeTranslator.getSerializationTypeForEncodingType(encodingType);
+        } catch (UnsupportedEncodingTypeException e) {
+          e.printStackTrace();
+        }
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java
new file mode 100644
index 0000000..2c37fb5
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java
@@ -0,0 +1,113 @@
+/*
+ * 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.serialization.registry;
+
+import org.apache.geode.serialization.SerializationType;
+import org.apache.geode.serialization.TypeCodec;
+import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@Category(UnitTest.class)
+@RunWith(PowerMockRunner.class)
+@PowerMockIgnore("*.UnitTest")
+@PrepareForTest({SerializationType.class})
+public class CodecRegistryJUnitTest {
+  private SerializationCodecRegistry codecRegistry;
+
+  @Before
+  public void startup() throws CodecAlreadyRegisteredForTypeException {
+    codecRegistry = new SerializationCodecRegistry();
+  }
+
+  @After
+  public void tearDown() {
+    codecRegistry.shutdown();
+  }
+
+  @Test
+  public void testRegisterCodec() throws CodecAlreadyRegisteredForTypeException {
+    Assert.assertEquals(10, codecRegistry.getRegisteredCodecCount());
+    SerializationType mockSerializationType = PowerMockito.mock(SerializationType.class);
+    codecRegistry.register(mockSerializationType, new DummyTypeCodec());
+    Assert.assertEquals(11, codecRegistry.getRegisteredCodecCount());
+  }
+
+  @Test
+  public void testRegisteringCodecForRegisteredType_throwsException()
+      throws CodecAlreadyRegisteredForTypeException {
+    SerializationType mockSerializationType = PowerMockito.mock(SerializationType.class);
+    codecRegistry.register(mockSerializationType, new DummyTypeCodec());
+
+    boolean caughtException = false;
+    try {
+      codecRegistry.register(mockSerializationType, new DummyTypeCodec());
+    } catch (CodecAlreadyRegisteredForTypeException e) {
+      caughtException = true;
+    }
+    Assert.assertTrue("This was supposed to have thrown a CodecAlreadyRegisteredException",
+        caughtException);
+  }
+
+  @Test
+  public void testGetRegisteredCodec()
+      throws CodecAlreadyRegisteredForTypeException, CodecNotRegisteredForTypeException {
+    TypeCodec expectedCodec = new DummyTypeCodec();
+    SerializationType mockSerializationType = PowerMockito.mock(SerializationType.class);
+    codecRegistry.register(mockSerializationType, expectedCodec);
+    TypeCodec codec = codecRegistry.getCodecForType(mockSerializationType);
+    Assert.assertSame(expectedCodec, codec);
+  }
+
+  @Test
+  public void testGetCodecForUnregisteredType_throwsException() {
+    boolean caughtException = false;
+    try {
+      SerializationType mockSerializationType = PowerMockito.mock(SerializationType.class);
+      codecRegistry.getCodecForType(mockSerializationType);
+    } catch (CodecNotRegisteredForTypeException e) {
+      caughtException = true;
+    }
+    Assert.assertTrue("This should have thrown a CodecNotRegisteredForTypeException",
+        caughtException);
+  }
+
+  class DummyTypeCodec implements TypeCodec {
+    @Override
+    public Object decode(byte[] incoming) {
+      return null;
+    }
+
+    @Override
+    public byte[] encode(Object incoming) {
+      return new byte[0];
+    }
+
+    @Override
+    public SerializationType getSerializationType() {
+      return PowerMockito.mock(SerializationType.class);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/gradle/rat.gradle
----------------------------------------------------------------------
diff --git a/gradle/rat.gradle b/gradle/rat.gradle
index 1bea584..a1582b9 100644
--- a/gradle/rat.gradle
+++ b/gradle/rat.gradle
@@ -113,11 +113,7 @@ rat {
     'geode-core/src/test/resources/org/apache/geode/management/internal/configuration/domain/CacheElementJUnitTest.xml',
     'geode-core/src/test/resources/org/apache/geode/management/internal/configuration/utils/*.xml',
 
-    '**/META-INF/services/org.xml.sax.ext.EntityResolver2',
-    '**/META-INF/services/org.apache.geode.internal.cache.CacheService',
-    '**/META-INF/services/org.apache.geode.internal.cache.xmlcache.XmlParser',
-    '**/META-INF/services/org.apache.geode.distributed.ServerLauncherCacheProvider',
-    '**/META-INF/services/org.springframework.shell.core.CommandMarker',
+    '**/META-INF/**',
 
     // --- Other Licenses ---
 

http://git-wip-us.apache.org/repos/asf/geode/blob/cdcc4d95/settings.gradle
----------------------------------------------------------------------
diff --git a/settings.gradle b/settings.gradle
index c0fdb6e..39697b7 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -37,8 +37,10 @@ include 'extensions/geode-modules-tomcat8'
 include 'extensions/geode-modules-session-internal'
 include 'extensions/geode-modules-session'
 include 'extensions/geode-modules-assembly'
-
+include 'geode-protobuf'
 
 if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion)) {
   throw new GradleException('Running with unsupported Gradle Version. Use Gradle Wrapper or with Gradle version >= ' + minimumGradleVersion)
 }
+
+


[26/46] geode git commit: GEODE-2919: Provide finer grained security

Posted by zh...@apache.org.
http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
index c04820e..21d89c1 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/FunctionCommands.java
@@ -14,6 +14,20 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.stream.Stream;
+
+import org.apache.commons.lang.BooleanUtils;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.execute.Execution;
@@ -40,7 +54,6 @@ import org.apache.geode.management.internal.cli.functions.ListFunctionFunction;
 import org.apache.geode.management.internal.cli.functions.UnregisterFunction;
 import org.apache.geode.management.internal.cli.functions.UserFunctionExecution;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.result.CommandResultException;
 import org.apache.geode.management.internal.cli.result.CompositeResultData;
 import org.apache.geode.management.internal.cli.result.ErrorResultData;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
@@ -48,18 +61,7 @@ import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
+import org.apache.geode.security.ResourcePermission.Target;
 
 /**
  * @since GemFire 7.0
@@ -77,25 +79,18 @@ public class FunctionCommands implements GfshCommand {
       @CliOption(key = CliStrings.EXECUTE_FUNCTION__ID, mandatory = true,
           help = CliStrings.EXECUTE_FUNCTION__ID__HELP) String functionId,
       @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           optionContext = ConverterHint.MEMBERGROUP,
           help = CliStrings.EXECUTE_FUNCTION__ONGROUPS__HELP) String[] onGroups,
-      @CliOption(key = CliStrings.MEMBER,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
-          optionContext = ConverterHint.MEMBERIDNAME,
+      @CliOption(key = CliStrings.MEMBER, optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.EXECUTE_FUNCTION__ONMEMBER__HELP) String onMember,
       @CliOption(key = CliStrings.EXECUTE_FUNCTION__ONREGION,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           optionContext = ConverterHint.REGION_PATH,
           help = CliStrings.EXECUTE_FUNCTION__ONREGION__HELP) String onRegion,
       @CliOption(key = CliStrings.EXECUTE_FUNCTION__ARGUMENTS,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.EXECUTE_FUNCTION__ARGUMENTS__HELP) String[] arguments,
       @CliOption(key = CliStrings.EXECUTE_FUNCTION__RESULTCOLLECTOR,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.EXECUTE_FUNCTION__RESULTCOLLECTOR__HELP) String resultCollector,
       @CliOption(key = CliStrings.EXECUTE_FUNCTION__FILTER,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.EXECUTE_FUNCTION__FILTER__HELP) String filterString) {
 
     Result result = null;
@@ -105,8 +100,8 @@ public class FunctionCommands implements GfshCommand {
     resultTable.setHeader(headerText);
     ResultCollector resultCollectorInstance = null;
     Function function;
-    Set<String> filters = new HashSet<String>();
-    Execution execution = null;
+    Set<String> filters = new HashSet<>();
+    Execution execution;
     if (functionId != null) {
       functionId = functionId.trim();
     }
@@ -130,31 +125,8 @@ public class FunctionCommands implements GfshCommand {
         return result;
       }
 
-      if (onRegion != null && onMember != null && onGroups != null) {
-        ErrorResultData errorResultData =
-            ResultBuilder.createErrorResultData().setErrorCode(ResultBuilder.ERRORCODE_DEFAULT)
-                .addLine(CliStrings.EXECUTE_FUNCTION__MSG__OPTIONS);
-        result = ResultBuilder.buildResult(errorResultData);
-        return result;
-      } else if (onRegion != null && onMember != null) {
-        ErrorResultData errorResultData =
-            ResultBuilder.createErrorResultData().setErrorCode(ResultBuilder.ERRORCODE_DEFAULT)
-                .addLine(CliStrings.EXECUTE_FUNCTION__MSG__OPTIONS);
-        result = ResultBuilder.buildResult(errorResultData);
-        return result;
-      } else if (onMember != null && onGroups != null) {
-        ErrorResultData errorResultData =
-            ResultBuilder.createErrorResultData().setErrorCode(ResultBuilder.ERRORCODE_DEFAULT)
-                .addLine(CliStrings.EXECUTE_FUNCTION__MSG__OPTIONS);
-        result = ResultBuilder.buildResult(errorResultData);
-        return result;
-      } else if (onRegion != null && onGroups != null) {
-        ErrorResultData errorResultData =
-            ResultBuilder.createErrorResultData().setErrorCode(ResultBuilder.ERRORCODE_DEFAULT)
-                .addLine(CliStrings.EXECUTE_FUNCTION__MSG__OPTIONS);
-        result = ResultBuilder.buildResult(errorResultData);
-        return result;
-      } else if (onRegion != null && onMember != null && onGroups != null) {
+      if (isMoreThanOneIsTrue(onRegion != null, onMember != null, onGroups != null)) {
+        // Provide Only one of region/member/groups
         ErrorResultData errorResultData =
             ResultBuilder.createErrorResultData().setErrorCode(ResultBuilder.ERRORCODE_DEFAULT)
                 .addLine(CliStrings.EXECUTE_FUNCTION__MSG__OPTIONS);
@@ -218,7 +190,7 @@ public class FunctionCommands implements GfshCommand {
           boolean matchFound = false;
 
           if (membersName.length > 0) {
-            while (it.hasNext() && matchFound == false) {
+            while (it.hasNext() && !matchFound) {
               DistributedMember dsmember = (DistributedMember) it.next();
               for (String memberName : membersName) {
                 if (MBeanJMXAdapter.getMemberNameOrId(dsmember).equals(memberName)) {
@@ -229,7 +201,7 @@ public class FunctionCommands implements GfshCommand {
               }
             }
           }
-          if (matchFound == true) {
+          if (matchFound) {
             executeAndGetResults(functionId, filterString, resultCollector, arguments, cache,
                 member, resultTable, onRegion);
             return ResultBuilder.buildResult(resultTable);
@@ -276,7 +248,7 @@ public class FunctionCommands implements GfshCommand {
         }
       } else if (onGroups != null) {
         // execute on group members
-        Set<DistributedMember> dsMembers = new HashSet<DistributedMember>();
+        Set<DistributedMember> dsMembers = new HashSet<>();
         for (String grp : onGroups) {
           dsMembers.addAll(cache.getDistributedSystem().getGroupMembers(grp));
         }
@@ -310,26 +282,6 @@ public class FunctionCommands implements GfshCommand {
         }
         return ResultBuilder.buildResult(resultTable);
       }
-    } catch (InstantiationException e) {
-      ErrorResultData errorResultData = ResultBuilder.createErrorResultData()
-          .setErrorCode(ResultBuilder.ERRORCODE_DEFAULT).addLine(e.getMessage());
-      result = ResultBuilder.buildResult(errorResultData);
-      return result;
-    } catch (IllegalAccessException e) {
-      ErrorResultData errorResultData = ResultBuilder.createErrorResultData()
-          .setErrorCode(ResultBuilder.ERRORCODE_DEFAULT).addLine(e.getMessage());
-      result = ResultBuilder.buildResult(errorResultData);
-      return result;
-    } catch (IllegalArgumentException e) {
-      ErrorResultData errorResultData = ResultBuilder.createErrorResultData()
-          .setErrorCode(ResultBuilder.ERRORCODE_DEFAULT).addLine(e.getMessage());
-      result = ResultBuilder.buildResult(errorResultData);
-      return result;
-    } catch (SecurityException e) {
-      ErrorResultData errorResultData = ResultBuilder.createErrorResultData()
-          .setErrorCode(ResultBuilder.ERRORCODE_DEFAULT).addLine(e.getMessage());
-      result = ResultBuilder.buildResult(errorResultData);
-      return result;
     } catch (Exception e) {
       ErrorResultData errorResultData = ResultBuilder.createErrorResultData()
           .setErrorCode(ResultBuilder.ERRORCODE_DEFAULT).addLine(e.getMessage());
@@ -340,10 +292,14 @@ public class FunctionCommands implements GfshCommand {
     return result;
   }
 
+  private boolean isMoreThanOneIsTrue(Boolean... values) {
+    return Stream.of(values).mapToInt(BooleanUtils::toInteger).sum() > 1;
+  }
+
   void executeAndGetResults(String functionId, String filterString, String resultCollector,
       String[] arguments, InternalCache cache, DistributedMember member,
       TabularResultData resultTable, String onRegion) {
-    StringBuilder resultMessege = new StringBuilder();
+    StringBuilder resultMessage = new StringBuilder();
     try {
       Function function = new UserFunctionExecution();
       Object[] args = new Object[5];
@@ -355,7 +311,7 @@ public class FunctionCommands implements GfshCommand {
         args[2] = resultCollector;
       }
       if (arguments != null && arguments.length > 0) {
-        args[3] = new String();
+        args[3] = "";
         for (String str : arguments) {
           // send via CSV separated value format
           if (str != null) {
@@ -372,30 +328,25 @@ public class FunctionCommands implements GfshCommand {
           for (Object resultObj : results) {
             if (resultObj != null) {
               if (resultObj instanceof String) {
-                resultMessege.append(((String) resultObj));
+                resultMessage.append(((String) resultObj));
               } else if (resultObj instanceof Exception) {
-                resultMessege.append(((Exception) resultObj).getMessage());
+                resultMessage.append(((Exception) resultObj).getMessage());
               } else {
-                resultMessege.append(resultObj);
+                resultMessage.append(resultObj);
               }
             }
           }
         }
-        toTabularResultData(resultTable, member.getId(), resultMessege.toString());
+        toTabularResultData(resultTable, member.getId(), resultMessage.toString());
       } else {
         toTabularResultData(resultTable, member.getId(),
             CliStrings.EXECUTE_FUNCTION__MSG__ERROR_IN_RETRIEVING_EXECUTOR);
       }
-    } catch (FunctionException e) {
-      resultMessege.append(CliStrings.format(
-          CliStrings.EXECUTE_FUNCTION__MSG__COULD_NOT_EXECUTE_FUNCTION_0_ON_MEMBER_1_ERROR_2,
-          functionId, member.getId(), e.getMessage()));
-      toTabularResultData(resultTable, member.getId(), resultMessege.toString());
     } catch (Exception e) {
-      resultMessege.append(CliStrings.format(
+      resultMessage.append(CliStrings.format(
           CliStrings.EXECUTE_FUNCTION__MSG__COULD_NOT_EXECUTE_FUNCTION_0_ON_MEMBER_1_ERROR_2,
           functionId, member.getId(), e.getMessage()));
-      toTabularResultData(resultTable, member.getId(), resultMessege.toString());
+      toTabularResultData(resultTable, member.getId(), resultMessage.toString());
     }
   }
 
@@ -409,23 +360,20 @@ public class FunctionCommands implements GfshCommand {
   @CliCommand(value = CliStrings.DESTROY_FUNCTION, help = CliStrings.DESTROY_FUNCTION__HELP)
   @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_FUNCTION},
       interceptor = "org.apache.geode.management.internal.cli.commands.FunctionCommands$Interceptor")
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE, target = Target.JAR)
   // TODO: Add optioncontext for functionId
   public Result destroyFunction(
       @CliOption(key = CliStrings.DESTROY_FUNCTION__ID, mandatory = true,
           help = CliStrings.DESTROY_FUNCTION__HELP) String functionId,
       @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           optionContext = ConverterHint.MEMBERGROUP,
           help = CliStrings.DESTROY_FUNCTION__ONGROUPS__HELP) String[] groups,
-      @CliOption(key = CliStrings.MEMBER,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
-          optionContext = ConverterHint.MEMBERIDNAME,
+      @CliOption(key = CliStrings.MEMBER, optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.DESTROY_FUNCTION__ONMEMBER__HELP) String memberId) {
-    Result result = null;
+    Result result;
     try {
       InternalCache cache = getCache();
-      Set<DistributedMember> dsMembers = new HashSet<DistributedMember>();
+      Set<DistributedMember> dsMembers = new HashSet<>();
       if (groups != null && memberId != null) {
         return ResultBuilder
             .createUserErrorResult(CliStrings.DESTROY_FUNCTION__MSG__PROVIDE_OPTION);
@@ -489,7 +437,7 @@ public class FunctionCommands implements GfshCommand {
     // unregister on a set of of members
     Function unregisterFunction = new UnregisterFunction();
     FunctionService.registerFunction(unregisterFunction);
-    List resultList = null;
+    List resultList;
 
     if (DsMembers.isEmpty()) {
       return ResultBuilder.createInfoResult("No members for execution");
@@ -564,9 +512,9 @@ public class FunctionCommands implements GfshCommand {
         } else if (result.isSuccessful()) {
           String[] strings = (String[]) result.getSerializables();
           Arrays.sort(strings);
-          for (int i = 0; i < strings.length; i++) {
+          for (String string : strings) {
             tabularData.accumulate("Member", result.getMemberIdOrName());
-            tabularData.accumulate("Function", strings[i]);
+            tabularData.accumulate("Function", string);
             accumulatedData = true;
           }
         }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GfshCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GfshCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GfshCommand.java
index 86296b4..88f730e 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GfshCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GfshCommand.java
@@ -14,7 +14,14 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.commons.lang.StringUtils;
+import org.springframework.shell.core.CommandMarker;
+
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.Function;
@@ -23,17 +30,12 @@ import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.distributed.internal.ClusterConfigurationService;
 import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.security.SecurityService;
 import org.apache.geode.management.cli.CliMetaData;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
 import org.apache.geode.management.internal.cli.util.MemberNotFoundException;
-import org.springframework.shell.core.CommandMarker;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.HashSet;
-import java.util.Set;
 
 /**
  * Encapsulates common functionality for implementing command classes for the Geode shell (gfsh).
@@ -102,6 +104,10 @@ public interface GfshCommand extends CommandMarker {
     return (InternalCache) CacheFactory.getAnyInstance();
   }
 
+  default SecurityService getSecurityService() {
+    return getCache().getSecurityService();
+  }
+
   default Gfsh getGfsh() {
     return Gfsh.getCurrentInstance();
   }
@@ -129,7 +135,7 @@ public interface GfshCommand extends CommandMarker {
    */
   @Deprecated
   default Set<DistributedMember> getMembers(final InternalCache cache) {
-    Set<DistributedMember> members = new HashSet<DistributedMember>(cache.getMembers());
+    Set<DistributedMember> members = new HashSet<>(cache.getMembers());
     members.add(cache.getDistributedSystem().getDistributedMember());
     return members;
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
index 4d8d5fe..4734b4c 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/IndexCommands.java
@@ -14,7 +14,20 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.atomic.AtomicReference;
+
 import org.apache.commons.lang.ArrayUtils;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
@@ -23,7 +36,6 @@ import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.FunctionInvocationTargetException;
 import org.apache.geode.cache.execute.ResultCollector;
 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.lang.StringUtils;
 import org.apache.geode.management.cli.CliMetaData;
@@ -47,18 +59,7 @@ import org.apache.geode.management.internal.configuration.domain.XmlEntity;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.concurrent.atomic.AtomicReference;
+import org.apache.geode.security.ResourcePermission.Target;
 
 /**
  * The IndexCommands class encapsulates all GemFire shell (Gfsh) commands related to indexes defined
@@ -80,10 +81,9 @@ public class IndexCommands implements GfshCommand {
       Collections.synchronizedSet(new HashSet<IndexInfo>());
 
   @CliCommand(value = CliStrings.LIST_INDEX, help = CliStrings.LIST_INDEX__HELP)
-  @CliMetaData(shellOnly = false,
-      relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
-  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
-  public Result listIndex(@CliOption(key = CliStrings.LIST_INDEX__STATS, mandatory = false,
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ, target = Target.QUERY)
+  public Result listIndex(@CliOption(key = CliStrings.LIST_INDEX__STATS,
       specifiedDefaultValue = "true", unspecifiedDefaultValue = "false",
       help = CliStrings.LIST_INDEX__STATS__HELP) final boolean showStats) {
     try {
@@ -114,7 +114,7 @@ public class IndexCommands implements GfshCommand {
         functionExecutor.execute(new ListIndexFunction());
 
     final List<?> results = (List<?>) resultsCollector.getResult();
-    final List<IndexDetails> indexDetailsList = new ArrayList<IndexDetails>(results.size());
+    final List<IndexDetails> indexDetailsList = new ArrayList<>(results.size());
 
     for (Object result : results) {
       if (result instanceof Set) { // ignore FunctionInvocationTargetExceptions and other Exceptions
@@ -161,9 +161,10 @@ public class IndexCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.CREATE_INDEX, help = CliStrings.CREATE_INDEX__HELP)
-  @CliMetaData(shellOnly = false,
-      relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
   // TODO : Add optionContext for indexName
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
   public Result createIndex(@CliOption(key = CliStrings.CREATE_INDEX__NAME, mandatory = true,
       help = CliStrings.CREATE_INDEX__NAME__HELP) final String indexName,
 
@@ -174,26 +175,25 @@ public class IndexCommands implements GfshCommand {
           optionContext = ConverterHint.REGION_PATH,
           help = CliStrings.CREATE_INDEX__REGION__HELP) String regionPath,
 
-      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS}, mandatory = false,
+      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
           optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.CREATE_INDEX__MEMBER__HELP) final String[] memberNameOrID,
 
-      @CliOption(key = CliStrings.CREATE_INDEX__TYPE, mandatory = false,
-          unspecifiedDefaultValue = "range", optionContext = ConverterHint.INDEX_TYPE,
+      @CliOption(key = CliStrings.CREATE_INDEX__TYPE, unspecifiedDefaultValue = "range",
+          optionContext = ConverterHint.INDEX_TYPE,
           help = CliStrings.CREATE_INDEX__TYPE__HELP) final String indexType,
 
-      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS}, mandatory = false,
+      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
           optionContext = ConverterHint.MEMBERGROUP,
           help = CliStrings.CREATE_INDEX__GROUP__HELP) final String[] group) {
 
-    Result result = null;
+    Result result;
     AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
 
-    getCache().getSecurityService().authorizeRegionManage(regionPath);
     try {
       final Cache cache = CacheFactory.getAnyInstance();
 
-      int idxType = IndexInfo.RANGE_INDEX;
+      int idxType;
 
       // Index type check
       if ("range".equalsIgnoreCase(indexType)) {
@@ -235,8 +235,8 @@ public class IndexCommands implements GfshCommand {
           CliUtil.executeFunction(createIndexFunction, indexInfo, targetMembers);
 
       final List<Object> funcResults = (List<Object>) rc.getResult();
-      final Set<String> successfulMembers = new TreeSet<String>();
-      final Map<String, Set<String>> indexOpFailMap = new HashMap<String, Set<String>>();
+      final Set<String> successfulMembers = new TreeSet<>();
+      final Map<String, Set<String>> indexOpFailMap = new HashMap<>();
 
       for (final Object funcResult : funcResults) {
         if (funcResult instanceof CliFunctionResult) {
@@ -253,7 +253,7 @@ public class IndexCommands implements GfshCommand {
             Set<String> failedMembers = indexOpFailMap.get(exceptionMessage);
 
             if (failedMembers == null) {
-              failedMembers = new TreeSet<String>();
+              failedMembers = new TreeSet<>();
             }
             failedMembers.add(cliFunctionResult.getMemberIdOrName());
             indexOpFailMap.put(exceptionMessage, failedMembers);
@@ -314,25 +314,25 @@ public class IndexCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.DESTROY_INDEX, help = CliStrings.DESTROY_INDEX__HELP)
-  @CliMetaData(shellOnly = false,
-      relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
-  public Result destroyIndex(@CliOption(key = CliStrings.DESTROY_INDEX__NAME, mandatory = false,
-      unspecifiedDefaultValue = "",
-      help = CliStrings.DESTROY_INDEX__NAME__HELP) final String indexName,
-
-      @CliOption(key = CliStrings.DESTROY_INDEX__REGION, mandatory = false,
-          optionContext = ConverterHint.REGION_PATH,
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
+  public Result destroyIndex(
+      @CliOption(key = CliStrings.DESTROY_INDEX__NAME, unspecifiedDefaultValue = "",
+          help = CliStrings.DESTROY_INDEX__NAME__HELP) final String indexName,
+
+      @CliOption(key = CliStrings.DESTROY_INDEX__REGION, optionContext = ConverterHint.REGION_PATH,
           help = CliStrings.DESTROY_INDEX__REGION__HELP) final String regionPath,
 
-      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS}, mandatory = false,
+      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
           optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.DESTROY_INDEX__MEMBER__HELP) final String[] memberNameOrID,
 
-      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS}, mandatory = false,
+      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
           optionContext = ConverterHint.MEMBERGROUP,
           help = CliStrings.DESTROY_INDEX__GROUP__HELP) final String[] group) {
 
-    Result result = null;
+    Result result;
 
     if (StringUtils.isBlank(indexName) && StringUtils.isBlank(regionPath)
         && ArrayUtils.isEmpty(group) && ArrayUtils.isEmpty(memberNameOrID)) {
@@ -340,18 +340,11 @@ public class IndexCommands implements GfshCommand {
           CliStrings.format(CliStrings.PROVIDE_ATLEAST_ONE_OPTION, CliStrings.DESTROY_INDEX));
     }
 
-    String regionName = null;
     final Cache cache = CacheFactory.getAnyInstance();
-
-    // If a regionName is specified, then authorize data manage on the regionName, otherwise, it
-    // requires data manage permission on all regions
-    if (StringUtils.isNotBlank(regionPath)) {
+    String regionName = null;
+    if (regionPath != null) {
       regionName = regionPath.startsWith("/") ? regionPath.substring(1) : regionPath;
-      getCache().getSecurityService().authorizeRegionManage(regionName);
-    } else {
-      getCache().getSecurityService().authorizeDataManage();
     }
-
     IndexInfo indexInfo = new IndexInfo(indexName, regionName);
     Set<DistributedMember> targetMembers = CliUtil.findMembers(group, memberNameOrID);
 
@@ -362,8 +355,8 @@ public class IndexCommands implements GfshCommand {
     ResultCollector rc = CliUtil.executeFunction(destroyIndexFunction, indexInfo, targetMembers);
     List<Object> funcResults = (List<Object>) rc.getResult();
 
-    Set<String> successfulMembers = new TreeSet<String>();
-    Map<String, Set<String>> indexOpFailMap = new HashMap<String, Set<String>>();
+    Set<String> successfulMembers = new TreeSet<>();
+    Map<String, Set<String>> indexOpFailMap = new HashMap<>();
 
     AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
     for (Object funcResult : funcResults) {
@@ -383,7 +376,7 @@ public class IndexCommands implements GfshCommand {
         Set<String> failedMembers = indexOpFailMap.get(exceptionMessage);
 
         if (failedMembers == null) {
-          failedMembers = new TreeSet<String>();
+          failedMembers = new TreeSet<>();
         }
         failedMembers.add(cliFunctionResult.getMemberIdOrName());
         indexOpFailMap.put(exceptionMessage, failedMembers);
@@ -451,9 +444,10 @@ public class IndexCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.DEFINE_INDEX, help = CliStrings.DEFINE_INDEX__HELP)
-  @CliMetaData(shellOnly = false,
-      relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
   // TODO : Add optionContext for indexName
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
   public Result defineIndex(@CliOption(key = CliStrings.DEFINE_INDEX_NAME, mandatory = true,
       help = CliStrings.DEFINE_INDEX__HELP) final String indexName,
 
@@ -464,16 +458,14 @@ public class IndexCommands implements GfshCommand {
           optionContext = ConverterHint.REGION_PATH,
           help = CliStrings.DEFINE_INDEX__REGION__HELP) String regionPath,
 
-      @CliOption(key = CliStrings.DEFINE_INDEX__TYPE, mandatory = false,
-          unspecifiedDefaultValue = "range", optionContext = ConverterHint.INDEX_TYPE,
+      @CliOption(key = CliStrings.DEFINE_INDEX__TYPE, unspecifiedDefaultValue = "range",
+          optionContext = ConverterHint.INDEX_TYPE,
           help = CliStrings.DEFINE_INDEX__TYPE__HELP) final String indexType) {
 
-    Result result = null;
+    Result result;
     XmlEntity xmlEntity = null;
 
-    getCache().getSecurityService().authorizeRegionManage(regionPath);
-
-    int idxType = IndexInfo.RANGE_INDEX;
+    int idxType;
 
     // Index type check
     if ("range".equalsIgnoreCase(indexType)) {
@@ -518,21 +510,21 @@ public class IndexCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.CREATE_DEFINED_INDEXES, help = CliStrings.CREATE_DEFINED__HELP)
-  @CliMetaData(shellOnly = false,
-      relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
   // TODO : Add optionContext for indexName
   public Result createDefinedIndexes(
 
-      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS}, mandatory = false,
+      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
           optionContext = ConverterHint.MEMBERIDNAME,
           help = CliStrings.CREATE_DEFINED_INDEXES__MEMBER__HELP) final String[] memberNameOrID,
 
-      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS}, mandatory = false,
+      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
           optionContext = ConverterHint.MEMBERGROUP,
           help = CliStrings.CREATE_DEFINED_INDEXES__GROUP__HELP) final String[] group) {
 
-    Result result = null;
+    Result result;
     AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
 
     if (indexDefinitions.isEmpty()) {
@@ -553,8 +545,8 @@ public class IndexCommands implements GfshCommand {
           CliUtil.executeFunction(createDefinedIndexesFunction, indexDefinitions, targetMembers);
 
       final List<Object> funcResults = (List<Object>) rc.getResult();
-      final Set<String> successfulMembers = new TreeSet<String>();
-      final Map<String, Set<String>> indexOpFailMap = new HashMap<String, Set<String>>();
+      final Set<String> successfulMembers = new TreeSet<>();
+      final Map<String, Set<String>> indexOpFailMap = new HashMap<>();
 
       for (final Object funcResult : funcResults) {
         if (funcResult instanceof CliFunctionResult) {
@@ -571,7 +563,7 @@ public class IndexCommands implements GfshCommand {
             Set<String> failedMembers = indexOpFailMap.get(exceptionMessage);
 
             if (failedMembers == null) {
-              failedMembers = new TreeSet<String>();
+              failedMembers = new TreeSet<>();
             }
             failedMembers.add(cliFunctionResult.getMemberIdOrName());
             indexOpFailMap.put(exceptionMessage, failedMembers);
@@ -624,9 +616,9 @@ public class IndexCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.CLEAR_DEFINED_INDEXES, help = CliStrings.CLEAR_DEFINED__HELP)
-  @CliMetaData(shellOnly = false,
-      relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA})
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE,
+      target = Target.QUERY)
   // TODO : Add optionContext for indexName
   public Result clearDefinedIndexes() {
     indexDefinitions.clear();

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
index 637fa0e..1415bc6 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
@@ -14,7 +14,41 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.zip.DataFormatException;
+import java.util.zip.GZIPInputStream;
+
+import javax.management.ObjectName;
+
 import org.apache.commons.lang.StringUtils;
+import org.apache.logging.log4j.Logger;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.LogWriter;
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.Function;
@@ -60,7 +94,6 @@ import org.apache.geode.management.internal.cli.functions.NetstatFunction.Netsta
 import org.apache.geode.management.internal.cli.functions.ShutDownFunction;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.remote.CommandExecutionContext;
-import org.apache.geode.management.internal.cli.result.CommandResultException;
 import org.apache.geode.management.internal.cli.result.CompositeResultData;
 import org.apache.geode.management.internal.cli.result.CompositeResultData.SectionResultData;
 import org.apache.geode.management.internal.cli.result.ErrorResultData;
@@ -72,39 +105,6 @@ import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.apache.logging.log4j.Logger;
-import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.zip.DataFormatException;
-import java.util.zip.GZIPInputStream;
-import javax.management.ObjectName;
 
 /**
  * @since GemFire 7.0
@@ -172,7 +172,7 @@ public class MiscellaneousCommands implements GfshCommand {
         return ResultBuilder.createInfoResult(CliStrings.SHUTDOWN__MSG__IMPROPER_TIMEOUT);
       }
 
-      // convert to mili-seconds
+      // convert to milliseconds
       long timeout = userSpecifiedTimeout * 1000;
 
       InternalCache cache = getCache();
@@ -211,7 +211,7 @@ public class MiscellaneousCommands implements GfshCommand {
         }
 
         for (DistributedMember locator : locators) {
-          Set<DistributedMember> lsSet = new HashSet<DistributedMember>();
+          Set<DistributedMember> lsSet = new HashSet<>();
           lsSet.add(locator);
           long elapsedTime = shutDownNodeWithTimeOut(timeout, lsSet);
           timeout = timeout - elapsedTime;
@@ -224,7 +224,7 @@ public class MiscellaneousCommands implements GfshCommand {
         return ResultBuilder.createInfoResult("Shutdown is triggered");
       }
       // now shut down this manager
-      Set<DistributedMember> mgrSet = new HashSet<DistributedMember>();
+      Set<DistributedMember> mgrSet = new HashSet<>();
       mgrSet.add(manager);
       // No need to check further timeout as this is the last node we will be
       // shutting down
@@ -290,18 +290,16 @@ public class MiscellaneousCommands implements GfshCommand {
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE)
   public Result gc(
       @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.GC__GROUP__HELP) String[] groups,
       @CliOption(key = CliStrings.MEMBER, optionContext = ConverterHint.ALL_MEMBER_IDNAME,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.GC__MEMBER__HELP) String memberId) {
     InternalCache cache = getCache();
-    Result result = null;
+    Result result;
     CompositeResultData gcResultTable = ResultBuilder.createCompositeResultData();
     TabularResultData resultTable = gcResultTable.addSection().addTable("Table1");
     String headerText = "GC Summary";
     resultTable.setHeader(headerText);
-    Set<DistributedMember> dsMembers = new HashSet<DistributedMember>();
+    Set<DistributedMember> dsMembers = new HashSet<>();
     if (memberId != null && memberId.length() > 0) {
       DistributedMember member = CliUtil.getDistributedMemberByNameOrId(memberId);
       if (member == null) {
@@ -328,13 +326,12 @@ public class MiscellaneousCommands implements GfshCommand {
 
   Result executeAndBuildResult(TabularResultData resultTable, Set<DistributedMember> dsMembers) {
     try {
-      List<?> resultList = null;
+      List<?> resultList;
       Function garbageCollectionFunction = new GarbageCollectionFunction();
       resultList =
           (List<?>) CliUtil.executeFunction(garbageCollectionFunction, null, dsMembers).getResult();
 
-      for (int i = 0; i < resultList.size(); i++) {
-        Object object = resultList.get(i);
+      for (Object object : resultList) {
         if (object instanceof Exception) {
           LogWrapper.getInstance().fine("Exception in GC " + ((Throwable) object).getMessage(),
               ((Throwable) object));
@@ -380,24 +377,20 @@ public class MiscellaneousCommands implements GfshCommand {
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   // TODO : Verify the auto-completion for multiple values.
   public Result netstat(
-      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS}, mandatory = false,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
+      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
           optionContext = ConverterHint.ALL_MEMBER_IDNAME,
           help = CliStrings.NETSTAT__MEMBER__HELP) String[] members,
-      @CliOption(key = CliStrings.GROUP, mandatory = false,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
-          optionContext = ConverterHint.MEMBERGROUP,
+      @CliOption(key = CliStrings.GROUP, optionContext = ConverterHint.MEMBERGROUP,
           help = CliStrings.NETSTAT__GROUP__HELP) String group,
       @CliOption(key = CliStrings.NETSTAT__FILE,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.NETSTAT__FILE__HELP) String saveAs,
       @CliOption(key = CliStrings.NETSTAT__WITHLSOF, specifiedDefaultValue = "true",
           unspecifiedDefaultValue = "false",
           help = CliStrings.NETSTAT__WITHLSOF__HELP) boolean withlsof) {
-    Result result = null;
+    Result result;
 
-    Map<String, DistributedMember> hostMemberMap = new HashMap<String, DistributedMember>();
-    Map<String, List<String>> hostMemberListMap = new HashMap<String, List<String>>();
+    Map<String, DistributedMember> hostMemberMap = new HashMap<>();
+    Map<String, List<String>> hostMemberListMap = new HashMap<>();
 
     try {
       if (members != null && members.length > 0 && group != null) {
@@ -410,7 +403,7 @@ public class MiscellaneousCommands implements GfshCommand {
       InternalDistributedSystem system = InternalDistributedSystem.getConnectedInstance();
 
       if (members != null) {
-        Set<String> notFoundMembers = new HashSet<String>();
+        Set<String> notFoundMembers = new HashSet<>();
         for (String memberIdOrName : members) {
           Set<DistributedMember> membersToExecuteOn = CliUtil.getAllMembers(system);
           boolean memberFound = false;
@@ -435,7 +428,7 @@ public class MiscellaneousCommands implements GfshCommand {
                   new Object[] {CliUtil.collectionToString(notFoundMembers, -1)}));
         }
       } else {
-        Set<DistributedMember> membersToExecuteOn = null;
+        Set<DistributedMember> membersToExecuteOn;
         if (group != null) {
           membersToExecuteOn = system.getGroupMembers(group);
         } else {
@@ -453,7 +446,7 @@ public class MiscellaneousCommands implements GfshCommand {
         }
       }
 
-      String lineSeparatorToUse = null;
+      String lineSeparatorToUse;
       lineSeparatorToUse = CommandExecutionContext.getShellLineSeparator();
       if (lineSeparatorToUse == null) {
         lineSeparatorToUse = GfshParser.LINE_SEPARATOR;
@@ -461,13 +454,12 @@ public class MiscellaneousCommands implements GfshCommand {
       NetstatFunctionArgument nfa = new NetstatFunctionArgument(lineSeparatorToUse, withlsof);
 
       if (!hostMemberMap.isEmpty()) {
-        Set<DistributedMember> membersToExecuteOn =
-            new HashSet<DistributedMember>(hostMemberMap.values());
+        Set<DistributedMember> membersToExecuteOn = new HashSet<>(hostMemberMap.values());
         ResultCollector<?, ?> netstatResult =
             CliUtil.executeFunction(NetstatFunction.INSTANCE, nfa, membersToExecuteOn);
         List<?> resultList = (List<?>) netstatResult.getResult();
-        for (int i = 0; i < resultList.size(); i++) {
-          NetstatFunctionResult netstatFunctionResult = (NetstatFunctionResult) resultList.get(i);
+        for (Object aResultList : resultList) {
+          NetstatFunctionResult netstatFunctionResult = (NetstatFunctionResult) aResultList;
           DeflaterInflaterData deflaterInflaterData = netstatFunctionResult.getCompressedBytes();
           try {
             String remoteHost = netstatFunctionResult.getHost();
@@ -528,9 +520,9 @@ public class MiscellaneousCommands implements GfshCommand {
     }
 
     // Maintain all members for a host - display purpose
-    List<String> list = null;
+    List<String> list;
     if (!hostMemberListMap.containsKey(host)) {
-      list = new ArrayList<String>();
+      list = new ArrayList<>();
       hostMemberListMap.put(host, list);
     } else {
       list = hostMemberListMap.get(host);
@@ -539,13 +531,13 @@ public class MiscellaneousCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.SHOW_DEADLOCK, help = CliStrings.SHOW_DEADLOCK__HELP)
-  @CliMetaData(shellOnly = false, relatedTopic = {CliStrings.TOPIC_GEODE_DEBUG_UTIL})
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DEBUG_UTIL})
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   public Result showDeadlock(@CliOption(key = CliStrings.SHOW_DEADLOCK__DEPENDENCIES__FILE,
       help = CliStrings.SHOW_DEADLOCK__DEPENDENCIES__FILE__HELP,
       mandatory = true) String filename) {
 
-    Result result = null;
+    Result result;
     try {
       if (!filename.endsWith(".txt")) {
         return ResultBuilder
@@ -590,20 +582,19 @@ public class MiscellaneousCommands implements GfshCommand {
   }
 
   @CliCommand(value = CliStrings.SHOW_LOG, help = CliStrings.SHOW_LOG_HELP)
-  @CliMetaData(shellOnly = false, relatedTopic = {CliStrings.TOPIC_GEODE_DEBUG_UTIL})
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DEBUG_UTIL})
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   public Result showLog(
       @CliOption(key = CliStrings.MEMBER, optionContext = ConverterHint.ALL_MEMBER_IDNAME,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.SHOW_LOG_MEMBER_HELP, mandatory = true) String memberNameOrId,
       @CliOption(key = CliStrings.SHOW_LOG_LINE_NUM, unspecifiedDefaultValue = "0",
-          help = CliStrings.SHOW_LOG_LINE_NUM_HELP, mandatory = false) int numberOfLines) {
-    Result result = null;
+          help = CliStrings.SHOW_LOG_LINE_NUM_HELP) int numberOfLines) {
+    Result result;
     try {
       InternalCache cache = getCache();
       SystemManagementService service =
           (SystemManagementService) ManagementService.getExistingManagementService(cache);
-      MemberMXBean bean = null;
+      MemberMXBean bean;
       DistributedMember memberToBeInvoked = CliUtil.getDistributedMemberByNameOrId(memberNameOrId);
       if (memberToBeInvoked != null) {
         String memberId = memberToBeInvoked.getId();
@@ -655,7 +646,7 @@ public class MiscellaneousCommands implements GfshCommand {
    * Current implementation supports writing it to a file and returning the location of the file
    */
   @CliCommand(value = CliStrings.EXPORT_STACKTRACE, help = CliStrings.EXPORT_STACKTRACE__HELP)
-  @CliMetaData(shellOnly = false, relatedTopic = {CliStrings.TOPIC_GEODE_DEBUG_UTIL})
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DEBUG_UTIL})
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   public Result exportStackTrace(@CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
       optionContext = ConverterHint.ALL_MEMBER_IDNAME,
@@ -671,7 +662,7 @@ public class MiscellaneousCommands implements GfshCommand {
           unspecifiedDefaultValue = "false",
           help = CliStrings.EXPORT_STACKTRACE__FAIL__IF__FILE__PRESENT__HELP) boolean failIfFilePresent) {
 
-    Result result = null;
+    Result result;
     StringBuffer filePrefix = new StringBuffer("stacktrace");
 
     if (fileName == null) {
@@ -690,7 +681,7 @@ public class MiscellaneousCommands implements GfshCommand {
 
       InfoResultData resultData = ResultBuilder.createInfoResultData();
 
-      Map<String, byte[]> dumps = new HashMap<String, byte[]>();
+      Map<String, byte[]> dumps = new HashMap<>();
       Set<DistributedMember> targetMembers = CliUtil.findMembers(group, memberNameOrId);
       if (targetMembers.isEmpty()) {
         return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
@@ -735,7 +726,7 @@ public class MiscellaneousCommands implements GfshCommand {
         return ResultBuilder
             .createShellClientAbortOperationResult(CliStrings.EXPORT_STACKTRACE_MSG_ABORTING);
       } else {
-        // we dont to show any info result
+        // we don't to show any info result
         return ResultBuilder.createInfoResult("");
       }
     }
@@ -750,17 +741,15 @@ public class MiscellaneousCommands implements GfshCommand {
    * @throws IOException
    */
   private String writeStacksToFile(Map<String, byte[]> dumps, String fileName) throws IOException {
-    String filePath = null;
-    OutputStream os = null;
-    PrintWriter ps = null;
-    File outputFile = null;
+    String filePath;
+    PrintWriter ps;
+    File outputFile;
 
-    try {
-      outputFile = new File(fileName);
-      os = new FileOutputStream(outputFile);
+    outputFile = new File(fileName);
+    try (OutputStream os = new FileOutputStream(outputFile)) {
       ps = new PrintWriter(os);
 
-      for (Map.Entry<String, byte[]> entry : dumps.entrySet()) {
+      for (Entry<String, byte[]> entry : dumps.entrySet()) {
         ps.append("*** Stack-trace for member " + entry.getKey() + " ***");
         ps.flush();
         GZIPInputStream zipIn = new GZIPInputStream(new ByteArrayInputStream(entry.getValue()));
@@ -774,15 +763,13 @@ public class MiscellaneousCommands implements GfshCommand {
       }
       ps.flush();
       filePath = outputFile.getCanonicalPath();
-    } finally {
-      os.close();
     }
 
     return filePath;
   }
 
   @CliCommand(value = CliStrings.SHOW_METRICS, help = CliStrings.SHOW_METRICS__HELP)
-  @CliMetaData(shellOnly = false, relatedTopic = {CliStrings.TOPIC_GEODE_STATISTICS})
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_STATISTICS})
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
   public Result showMetrics(
       @CliOption(key = {CliStrings.MEMBER}, optionContext = ConverterHint.ALL_MEMBER_IDNAME,
@@ -796,7 +783,7 @@ public class MiscellaneousCommands implements GfshCommand {
       @CliOption(key = {CliStrings.SHOW_METRICS__CATEGORY},
           help = CliStrings.SHOW_METRICS__CATEGORY__HELP) String[] categories) {
 
-    Result result = null;
+    Result result;
     try {
 
       if (export_to_report_to != null && !export_to_report_to.isEmpty()) {
@@ -873,11 +860,10 @@ public class MiscellaneousCommands implements GfshCommand {
    * @return ResultData with required System wide statistics or ErrorResultData if DS MBean is not
    *         found to gather metrics
    */
-  private ResultData getSystemWideMetrics(String export_to_report_to, String[] categoriesArr)
-      throws Exception {
+  private ResultData getSystemWideMetrics(String export_to_report_to, String[] categoriesArr) {
     final InternalCache cache = getCache();
-    final ManagementService managmentService = ManagementService.getManagementService(cache);
-    DistributedSystemMXBean dsMxBean = managmentService.getDistributedSystemMXBean();
+    final ManagementService managementService = ManagementService.getManagementService(cache);
+    DistributedSystemMXBean dsMxBean = managementService.getDistributedSystemMXBean();
     StringBuilder csvBuilder = null;
     if (dsMxBean != null) {
 
@@ -898,7 +884,7 @@ public class MiscellaneousCommands implements GfshCommand {
 
       if (categoriesArr != null && categoriesArr.length != 0) {
         Set<String> categories = createSet(categoriesArr);
-        Set<String> checkSet = new HashSet<String>(categoriesMap.keySet());
+        Set<String> checkSet = new HashSet<>(categoriesMap.keySet());
         Set<String> userCategories = getSetDifference(categories, checkSet);
 
         // Checking if the categories specified by the user are valid or not
@@ -923,12 +909,12 @@ public class MiscellaneousCommands implements GfshCommand {
       }
       metricsTable.setHeader("Cluster-wide Metrics");
 
-      if (categoriesMap.get("cluster").booleanValue()) {
+      if (categoriesMap.get("cluster")) {
         writeToTableAndCsv(metricsTable, "cluster", "totalHeapSize", dsMxBean.getTotalHeapSize(),
             csvBuilder);
       }
 
-      if (categoriesMap.get("cache").booleanValue()) {
+      if (categoriesMap.get("cache")) {
         writeToTableAndCsv(metricsTable, "cache", "totalRegionEntryCount",
             dsMxBean.getTotalRegionEntryCount(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "totalRegionCount", dsMxBean.getTotalRegionCount(),
@@ -939,7 +925,7 @@ public class MiscellaneousCommands implements GfshCommand {
             csvBuilder);
       }
 
-      if (categoriesMap.get("diskstore").booleanValue()) {
+      if (categoriesMap.get("diskstore")) {
         writeToTableAndCsv(metricsTable, "diskstore", "totalDiskUsage",
             dsMxBean.getTotalDiskUsage(), csvBuilder); // deadcoded to workaround bug 46397
         writeToTableAndCsv(metricsTable, ""/* 46608 */, "diskReadsRate",
@@ -952,7 +938,7 @@ public class MiscellaneousCommands implements GfshCommand {
             dsMxBean.getTotalBackupInProgress(), csvBuilder);
       }
 
-      if (categoriesMap.get("query").booleanValue()) {
+      if (categoriesMap.get("query")) {
         writeToTableAndCsv(metricsTable, "query", "activeCQCount", dsMxBean.getActiveCQCount(),
             csvBuilder);
         writeToTableAndCsv(metricsTable, "", "queryRequestRate", dsMxBean.getQueryRequestRate(),
@@ -988,7 +974,7 @@ public class MiscellaneousCommands implements GfshCommand {
     ObjectName memberMBeanName = managementService.getMemberMBeanName(distributedMember);
     MemberMXBean memberMxBean =
         managementService.getMBeanInstance(memberMBeanName, MemberMXBean.class);
-    ObjectName csMxBeanName = null;
+    ObjectName csMxBeanName;
     CacheServerMXBean csMxBean = null;
 
     if (memberMxBean != null) {
@@ -1028,7 +1014,7 @@ public class MiscellaneousCommands implements GfshCommand {
 
       if (categoriesArr != null && categoriesArr.length != 0) {
         Set<String> categories = createSet(categoriesArr);
-        Set<String> checkSet = new HashSet<String>(categoriesMap.keySet());
+        Set<String> checkSet = new HashSet<>(categoriesMap.keySet());
         Set<String> userCategories = getSetDifference(categories, checkSet);
 
         // Checking if the categories specified by the user are valid or not
@@ -1056,7 +1042,7 @@ public class MiscellaneousCommands implements GfshCommand {
        */
       // member, jvm, region, serialization, communication, function, transaction, diskstore, lock,
       // eviction, distribution
-      if (categoriesMap.get("member").booleanValue()) {
+      if (categoriesMap.get("member")) {
         writeToTableAndCsv(metricsTable, "member", "upTime", memberMxBean.getMemberUpTime(),
             csvBuilder);
         writeToTableAndCsv(metricsTable, "", "cpuUsage", memberMxBean.getCpuUsage(), csvBuilder);
@@ -1068,7 +1054,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * JVM Metrics
        */
-      if (categoriesMap.get("jvm").booleanValue()) {
+      if (categoriesMap.get("jvm")) {
         writeToTableAndCsv(metricsTable, "jvm ", "jvmThreads ", jvmMetrics.getTotalThreads(),
             csvBuilder);
         writeToTableAndCsv(metricsTable, "", "fileDescriptorLimit",
@@ -1079,7 +1065,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Member wide region metrics
        */
-      if (categoriesMap.get("region").booleanValue()) {
+      if (categoriesMap.get("region")) {
         writeToTableAndCsv(metricsTable, "region ", "totalRegionCount ",
             memberMxBean.getTotalRegionCount(), csvBuilder);
         String[] regionNames = memberMxBean.listRegions();
@@ -1120,7 +1106,7 @@ public class MiscellaneousCommands implements GfshCommand {
             csvBuilder);
         writeToTableAndCsv(metricsTable, "", "putAllAvgLatency", memberMxBean.getPutAllAvgLatency(),
             csvBuilder);
-        // Not available from stats. After Stats re-org it will be avaialble
+        // Not available from stats. After Stats re-org it will be available
         // writeToTableAndCsv(metricsTable, "", "getAllAvgLatency",
         // memberMxBean.getGetAllAvgLatency(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "totalMissCount", memberMxBean.getTotalMissCount(),
@@ -1140,7 +1126,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * SERIALIZATION
        */
-      if (categoriesMap.get("serialization").booleanValue()) {
+      if (categoriesMap.get("serialization")) {
         writeToTableAndCsv(metricsTable, "serialization", "serializationRate",
             memberMxBean.getSerializationRate(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "serializationLatency",
@@ -1160,7 +1146,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Communication Metrics
        */
-      if (categoriesMap.get("communication").booleanValue()) {
+      if (categoriesMap.get("communication")) {
         writeToTableAndCsv(metricsTable, "communication", "bytesSentRate",
             memberMxBean.getBytesSentRate(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "bytesReceivedRate",
@@ -1177,23 +1163,20 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Member wide function metrics
        */
-      if (categoriesMap.get("function").booleanValue()) {
+      if (categoriesMap.get("function")) {
         writeToTableAndCsv(metricsTable, "function", "numRunningFunctions",
             memberMxBean.getNumRunningFunctions(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "functionExecutionRate",
             memberMxBean.getFunctionExecutionRate(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "numRunningFunctionsHavingResults",
             memberMxBean.getNumRunningFunctionsHavingResults(), csvBuilder);
-        // Not Avaialble from Stats
-        // writeToTableAndCsv(metricsTable, "", "funcExecutionQueueSize",
-        // memberMxBean.getFuncExecutionQueueSize(), csvBuilder);
       }
 
       /*
        * totalTransactionsCount currentTransactionalThreadIds transactionCommitsAvgLatency
        * transactionCommittedTotalCount transactionRolledBackTotalCount transactionCommitsRate
        */
-      if (categoriesMap.get("transaction").booleanValue()) {
+      if (categoriesMap.get("transaction")) {
         writeToTableAndCsv(metricsTable, "transaction", "totalTransactionsCount",
             memberMxBean.getTotalTransactionsCount(), csvBuilder);
 
@@ -1209,7 +1192,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Member wide disk metrics
        */
-      if (categoriesMap.get("diskstore").booleanValue()) {
+      if (categoriesMap.get("diskstore")) {
         writeToTableAndCsv(metricsTable, "diskstore", "totalDiskUsage",
             memberMxBean.getTotalDiskUsage(), csvBuilder); // deadcoded to workaround bug 46397
         writeToTableAndCsv(metricsTable, ""/* 46608 */, "diskReadsRate",
@@ -1227,7 +1210,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Member wide Lock
        */
-      if (categoriesMap.get("lock").booleanValue()) {
+      if (categoriesMap.get("lock")) {
         writeToTableAndCsv(metricsTable, "lock", "lockWaitsInProgress",
             memberMxBean.getLockWaitsInProgress(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "totalLockWaitTime",
@@ -1240,7 +1223,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Eviction
        */
-      if (categoriesMap.get("eviction").booleanValue()) {
+      if (categoriesMap.get("eviction")) {
         writeToTableAndCsv(metricsTable, "eviction", "lruEvictionRate",
             memberMxBean.getLruEvictionRate(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "lruDestroyRate", memberMxBean.getLruDestroyRate(),
@@ -1249,9 +1232,9 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Distribution
        */
-      if (categoriesMap.get("distribution").booleanValue()) {
+      if (categoriesMap.get("distribution")) {
         writeToTableAndCsv(metricsTable, "distribution", "getInitialImagesInProgress",
-            memberMxBean.getInitialImagesInProgres(), csvBuilder);
+            memberMxBean.getInitialImagesInProgress(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "getInitialImageTime",
             memberMxBean.getInitialImageTime(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "getInitialImageKeysReceived",
@@ -1261,7 +1244,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * OffHeap
        */
-      if (categoriesMap.get("offheap").booleanValue()) {
+      if (categoriesMap.get("offheap")) {
         writeToTableAndCsv(metricsTable, "offheap", "maxMemory", memberMxBean.getOffHeapMaxMemory(),
             csvBuilder);
         writeToTableAndCsv(metricsTable, "", "freeMemory", memberMxBean.getOffHeapFreeMemory(),
@@ -1381,7 +1364,7 @@ public class MiscellaneousCommands implements GfshCommand {
 
       if (categoriesArr != null && categoriesArr.length != 0) {
         Set<String> categories = createSet(categoriesArr);
-        Set<String> checkSet = new HashSet<String>(categoriesMap.keySet());
+        Set<String> checkSet = new HashSet<>(categoriesMap.keySet());
         Set<String> userCategories = getSetDifference(categories, checkSet);
 
         // Checking if the categories specified by the user are valid or not
@@ -1407,14 +1390,14 @@ public class MiscellaneousCommands implements GfshCommand {
        * General System metrics
        */
       // cluster, region, partition , diskstore, callback, eviction
-      if (categoriesMap.get("cluster").booleanValue()) {
+      if (categoriesMap.get("cluster")) {
         writeToTableAndCsv(metricsTable, "cluster", "member count", regionMxBean.getMemberCount(),
             csvBuilder);
         writeToTableAndCsv(metricsTable, "", "region entry count",
             regionMxBean.getSystemRegionEntryCount(), csvBuilder);
       }
 
-      if (categoriesMap.get("region").booleanValue()) {
+      if (categoriesMap.get("region")) {
         writeToTableAndCsv(metricsTable, "region", "lastModifiedTime",
             regionMxBean.getLastModifiedTime(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "lastAccessedTime", regionMxBean.getLastAccessedTime(),
@@ -1432,7 +1415,7 @@ public class MiscellaneousCommands implements GfshCommand {
             csvBuilder);
       }
 
-      if (categoriesMap.get("partition").booleanValue()) {
+      if (categoriesMap.get("partition")) {
         writeToTableAndCsv(metricsTable, "partition", "putLocalRate",
             regionMxBean.getPutLocalRate(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "putRemoteRate", regionMxBean.getPutRemoteRate(),
@@ -1456,7 +1439,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Disk store
        */
-      if (categoriesMap.get("diskstore").booleanValue()) {
+      if (categoriesMap.get("diskstore")) {
         writeToTableAndCsv(metricsTable, "diskstore", "totalEntriesOnlyOnDisk",
             regionMxBean.getTotalEntriesOnlyOnDisk(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "diskReadsRate", regionMxBean.getDiskReadsRate(),
@@ -1472,7 +1455,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * LISTENER
        */
-      if (categoriesMap.get("callback").booleanValue()) {
+      if (categoriesMap.get("callback")) {
         writeToTableAndCsv(metricsTable, "callback", "cacheWriterCallsAvgLatency",
             regionMxBean.getCacheWriterCallsAvgLatency(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "cacheListenerCallsAvgLatency",
@@ -1482,7 +1465,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Eviction
        */
-      if (categoriesMap.get("eviction").booleanValue()) {
+      if (categoriesMap.get("eviction")) {
         writeToTableAndCsv(metricsTable, "eviction", "lruEvictionRate",
             regionMxBean.getLruEvictionRate(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "lruDestroyRate", regionMxBean.getLruDestroyRate(),
@@ -1549,7 +1532,7 @@ public class MiscellaneousCommands implements GfshCommand {
 
       if (categoriesArr != null && categoriesArr.length != 0) {
         Set<String> categories = createSet(categoriesArr);
-        Set<String> checkSet = new HashSet<String>(categoriesMap.keySet());
+        Set<String> checkSet = new HashSet<>(categoriesMap.keySet());
         Set<String> userCategories = getSetDifference(categories, checkSet);
 
         // Checking if the categories specified by the user are valid or not
@@ -1572,7 +1555,7 @@ public class MiscellaneousCommands implements GfshCommand {
         }
       }
 
-      if (categoriesMap.get("region").booleanValue()) {
+      if (categoriesMap.get("region")) {
         writeToTableAndCsv(metricsTable, "region", "lastModifiedTime",
             regionMxBean.getLastModifiedTime(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "lastAccessedTime", regionMxBean.getLastAccessedTime(),
@@ -1590,7 +1573,7 @@ public class MiscellaneousCommands implements GfshCommand {
             csvBuilder);
       }
 
-      if (categoriesMap.get("partition").booleanValue()) {
+      if (categoriesMap.get("partition")) {
         writeToTableAndCsv(metricsTable, "partition", "putLocalRate",
             regionMxBean.getPutLocalRate(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "putRemoteRate", regionMxBean.getPutRemoteRate(),
@@ -1616,7 +1599,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Disk store
        */
-      if (categoriesMap.get("diskstore").booleanValue()) {
+      if (categoriesMap.get("diskstore")) {
         writeToTableAndCsv(metricsTable, "diskstore", "totalEntriesOnlyOnDisk",
             regionMxBean.getTotalEntriesOnlyOnDisk(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "diskReadsRate", "" + regionMxBean.getDiskReadsRate(),
@@ -1631,7 +1614,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * LISTENER
        */
-      if (categoriesMap.get("callback").booleanValue()) {
+      if (categoriesMap.get("callback")) {
         writeToTableAndCsv(metricsTable, "callback", "cacheWriterCallsAvgLatency",
             regionMxBean.getCacheWriterCallsAvgLatency(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "cacheListenerCallsAvgLatency",
@@ -1641,7 +1624,7 @@ public class MiscellaneousCommands implements GfshCommand {
       /*
        * Eviction
        */
-      if (categoriesMap.get("eviction").booleanValue()) {
+      if (categoriesMap.get("eviction")) {
         writeToTableAndCsv(metricsTable, "eviction", "lruEvictionRate",
             regionMxBean.getLruEvictionRate(), csvBuilder);
         writeToTableAndCsv(metricsTable, "", "lruDestroyRate", regionMxBean.getLruDestroyRate(),
@@ -1686,7 +1669,7 @@ public class MiscellaneousCommands implements GfshCommand {
       double metricValue, StringBuilder csvBuilder) {
     metricsTable.accumulate(CliStrings.SHOW_METRICS__TYPE__HEADER, type);
     metricsTable.accumulate(CliStrings.SHOW_METRICS__METRIC__HEADER, metricName);
-    metricsTable.accumulate(CliStrings.SHOW_METRICS__VALUE__HEADER, Double.valueOf(metricValue));
+    metricsTable.accumulate(CliStrings.SHOW_METRICS__VALUE__HEADER, metricValue);
 
     if (csvBuilder != null) {
       csvBuilder.append(type);
@@ -1699,10 +1682,8 @@ public class MiscellaneousCommands implements GfshCommand {
   }
 
   private Set<String> createSet(String[] categories) {
-    Set<String> categoriesSet = new HashSet<String>();
-    for (String category : categories) {
-      categoriesSet.add(category);
-    }
+    Set<String> categoriesSet = new HashSet<>();
+    Collections.addAll(categoriesSet, categories);
     return categoriesSet;
   }
 
@@ -1712,7 +1693,7 @@ public class MiscellaneousCommands implements GfshCommand {
    * @return map with categories for system metrics and display flag set to true
    */
   private Map<String, Boolean> getSystemMetricsCategories() {
-    Map<String, Boolean> categories = new HashMap<String, Boolean>();
+    Map<String, Boolean> categories = new HashMap<>();
     categories.put("cluster", true);
     categories.put("cache", true);
     categories.put("diskstore", true);
@@ -1726,7 +1707,7 @@ public class MiscellaneousCommands implements GfshCommand {
    * @return map with categories for region metrics and display flag set to true
    */
   private Map<String, Boolean> getRegionMetricsCategories() {
-    Map<String, Boolean> categories = new HashMap<String, Boolean>();
+    Map<String, Boolean> categories = new HashMap<>();
 
     categories.put("region", true);
     categories.put("partition", true);
@@ -1756,7 +1737,7 @@ public class MiscellaneousCommands implements GfshCommand {
    * @return map with categories for member metrics and display flag set to true
    */
   private Map<String, Boolean> getMemberMetricsCategories() {
-    Map<String, Boolean> categories = new HashMap<String, Boolean>();
+    Map<String, Boolean> categories = new HashMap<>();
     categories.put("member", true);
     categories.put("jvm", true);
     categories.put("region", true);
@@ -1842,7 +1823,7 @@ public class MiscellaneousCommands implements GfshCommand {
       InternalCache cache = GemFireCacheImpl.getInstance();
       LogWriter logger = cache.getLogger();
 
-      Set<DistributedMember> dsMembers = new HashSet<DistributedMember>();
+      Set<DistributedMember> dsMembers = new HashSet<>();
       Set<DistributedMember> ds = CliUtil.getAllMembers(cache);
 
       if (grps != null && grps.length > 0) {
@@ -1853,9 +1834,7 @@ public class MiscellaneousCommands implements GfshCommand {
 
       if (memberIds != null && memberIds.length > 0) {
         for (String member : memberIds) {
-          Iterator<DistributedMember> it = ds.iterator();
-          while (it.hasNext()) {
-            DistributedMember mem = it.next();
+          for (DistributedMember mem : ds) {
             if (mem.getName() != null
                 && (mem.getName().equals(member) || mem.getId().equals(member))) {
               dsMembers.add(mem);
@@ -1909,7 +1888,6 @@ public class MiscellaneousCommands implements GfshCommand {
           }
         } catch (Exception ex) {
           LogWrapper.getInstance().warning("change log level command exception " + ex);
-          continue;
         }
       }
 
@@ -1937,7 +1915,7 @@ public class MiscellaneousCommands implements GfshCommand {
   }
 
   private Set<String> getSetDifference(Set<String> set1, Set<String> set2) {
-    Set<String> setDifference = new HashSet<String>();
+    Set<String> setDifference = new HashSet<>();
     for (String element : set1) {
       if (!(set2.contains(element.toLowerCase()))) {
         setDifference.add(element);

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PDXCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PDXCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PDXCommands.java
index 9bfd47b..e0bad15 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PDXCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/PDXCommands.java
@@ -14,6 +14,17 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.internal.cache.CacheConfig;
 import org.apache.geode.internal.cache.DiskStoreImpl;
 import org.apache.geode.internal.cache.xmlcache.CacheCreation;
@@ -32,42 +43,25 @@ import org.apache.geode.pdx.internal.EnumInfo;
 import org.apache.geode.pdx.internal.PdxType;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Arrays;
-import java.util.Collection;
 
 public class PDXCommands implements GfshCommand {
 
 
   @CliCommand(value = CliStrings.CONFIGURE_PDX, help = CliStrings.CONFIGURE_PDX__HELP)
   @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_REGION)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE)
   public Result configurePDX(
       @CliOption(key = CliStrings.CONFIGURE_PDX__READ__SERIALIZED,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.CONFIGURE_PDX__READ__SERIALIZED__HELP) Boolean readSerialized,
       @CliOption(key = CliStrings.CONFIGURE_PDX__IGNORE__UNREAD_FIELDS,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.CONFIGURE_PDX__IGNORE__UNREAD_FIELDS__HELP) Boolean ignoreUnreadFields,
-      @CliOption(key = CliStrings.CONFIGURE_PDX__DISKSTORE,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, specifiedDefaultValue = "",
+      @CliOption(key = CliStrings.CONFIGURE_PDX__DISKSTORE, specifiedDefaultValue = "",
           help = CliStrings.CONFIGURE_PDX__DISKSTORE__HELP) String diskStore,
       @CliOption(key = CliStrings.CONFIGURE_PDX__AUTO__SERIALIZER__CLASSES,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
-          specifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.CONFIGURE_PDX__AUTO__SERIALIZER__CLASSES__HELP) String[] patterns,
       @CliOption(key = CliStrings.CONFIGURE_PDX__PORTABLE__AUTO__SERIALIZER__CLASSES,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
-          specifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.CONFIGURE_PDX__PORTABLE__AUTO__SERIALIZER__CLASSES__HELP) String[] portablePatterns) {
-    Result result = null;
+    Result result;
 
     try {
       InfoResultData ird = ResultBuilder.createInfoResultData();
@@ -105,7 +99,7 @@ public class PDXCommands implements GfshCommand {
           CliStrings.CONFIGURE_PDX__READ__SERIALIZED + " = " + cache.getPdxReadSerialized());
 
 
-      // Set ingoreUnreadFields
+      // Set ignoreUnreadFields
       if (ignoreUnreadFields != null) {
         cache.setPdxIgnoreUnreadFields(ignoreUnreadFields);
       } else {
@@ -153,7 +147,6 @@ public class PDXCommands implements GfshCommand {
 
   @CliCommand(value = CliStrings.PDX_RENAME, help = CliStrings.PDX_RENAME__HELP)
   @CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GEODE_DISKSTORE})
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
   public Result pdxRename(@CliOption(key = CliStrings.PDX_RENAME_OLD, mandatory = true,
       help = CliStrings.PDX_RENAME_OLD__HELP) String oldClassName,
 
@@ -191,7 +184,7 @@ public class PDXCommands implements GfshCommand {
       }
       String resultString =
           CliStrings.format(CliStrings.PDX_RENAME__SUCCESS, outputStream.toString());
-      return ResultBuilder.createInfoResult(resultString.toString());
+      return ResultBuilder.createInfoResult(resultString);
 
     } catch (Exception e) {
       return ResultBuilder.createGemFireErrorResult(

http://git-wip-us.apache.org/repos/asf/geode/blob/451d12e8/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueueCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueueCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueueCommands.java
index 25b95cd..87c5bbc 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueueCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/QueueCommands.java
@@ -14,10 +14,18 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.management.cli.CliMetaData;
 import org.apache.geode.management.cli.ConverterHint;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.cli.Result.Status;
@@ -28,21 +36,13 @@ import org.apache.geode.management.internal.cli.functions.CliFunctionResult;
 import org.apache.geode.management.internal.cli.functions.CreateAsyncEventQueueFunction;
 import org.apache.geode.management.internal.cli.functions.ListAsyncEventQueuesFunction;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.result.CommandResultException;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
 import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.management.internal.configuration.domain.XmlEntity;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
-import org.springframework.shell.core.annotation.CliCommand;
-import org.springframework.shell.core.annotation.CliOption;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicReference;
+import org.apache.geode.security.ResourcePermission.Target;
 
 /**
  * The QueueCommands class encapsulates all GemFire Queue commands in Gfsh.
@@ -54,12 +54,11 @@ public class QueueCommands implements GfshCommand {
 
   @CliCommand(value = CliStrings.CREATE_ASYNC_EVENT_QUEUE,
       help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__HELP)
-  @ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
+  @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE, target = Target.JAR)
   public Result createAsyncEventQueue(
       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__ID, mandatory = true,
           help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__ID__HELP) String id,
       @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           optionContext = ConverterHint.MEMBERGROUP,
           help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__GROUP__HELP) String[] groups,
       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__PARALLEL,
@@ -78,7 +77,6 @@ public class QueueCommands implements GfshCommand {
           unspecifiedDefaultValue = "false", specifiedDefaultValue = "true",
           help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__PERSISTENT__HELP) boolean persistent,
       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISK_STORE,
-          unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
           help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISK_STORE__HELP) String diskStore,
       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISKSYNCHRONOUS,
           unspecifiedDefaultValue = "true", specifiedDefaultValue = "true",
@@ -104,17 +102,20 @@ public class QueueCommands implements GfshCommand {
       @CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER_PARAM_AND_VALUE,
           help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER_PARAM_AND_VALUE__HELP) String[] listenerParamsAndValues) {
 
+    if (persistent) {
+      getSecurityService().authorize(Resource.CLUSTER, Operation.WRITE, Target.DISK);
+    }
     Properties listenerProperties = new Properties();
 
     try {
       if (listenerParamsAndValues != null) {
-        for (int i = 0; i < listenerParamsAndValues.length; i++) {
-          final int hashPosition = listenerParamsAndValues[i].indexOf('#');
+        for (String listenerParamsAndValue : listenerParamsAndValues) {
+          final int hashPosition = listenerParamsAndValue.indexOf('#');
           if (hashPosition == -1) {
-            listenerProperties.put(listenerParamsAndValues[i], "");
+            listenerProperties.put(listenerParamsAndValue, "");
           } else {
-            listenerProperties.put(listenerParamsAndValues[i].substring(0, hashPosition),
-                listenerParamsAndValues[i].substring(hashPosition + 1));
+            listenerProperties.put(listenerParamsAndValue.substring(0, hashPosition),
+                listenerParamsAndValue.substring(hashPosition + 1));
           }
         }
       }
@@ -205,17 +206,17 @@ public class QueueCommands implements GfshCommand {
           tabularData.setStatus(Status.ERROR);
         } else {
           AsyncEventQueueDetails[] details = (AsyncEventQueueDetails[]) result.getSerializables();
-          for (int i = 0; i < details.length; i++) {
+          for (AsyncEventQueueDetails detail : details) {
             tabularData.accumulate("Member", result.getMemberIdOrName());
-            tabularData.accumulate("ID", details[i].getId());
-            tabularData.accumulate("Batch Size", details[i].getBatchSize());
-            tabularData.accumulate("Persistent", details[i].isPersistent());
-            tabularData.accumulate("Disk Store", details[i].getDiskStoreName());
-            tabularData.accumulate("Max Memory", details[i].getMaxQueueMemory());
+            tabularData.accumulate("ID", detail.getId());
+            tabularData.accumulate("Batch Size", detail.getBatchSize());
+            tabularData.accumulate("Persistent", detail.isPersistent());
+            tabularData.accumulate("Disk Store", detail.getDiskStoreName());
+            tabularData.accumulate("Max Memory", detail.getMaxQueueMemory());
 
-            Properties listenerProperties = details[i].getListenerProperties();
+            Properties listenerProperties = detail.getListenerProperties();
             if (listenerProperties == null || listenerProperties.size() == 0) {
-              tabularData.accumulate("Listener", details[i].getListener());
+              tabularData.accumulate("Listener", detail.getListener());
             } else {
               StringBuilder propsStringBuilder = new StringBuilder();
               propsStringBuilder.append('(');
@@ -232,7 +233,7 @@ public class QueueCommands implements GfshCommand {
               propsStringBuilder.append(')');
 
               tabularData.accumulate("Listener",
-                  details[i].getListener() + propsStringBuilder.toString());
+                  detail.getListener() + propsStringBuilder.toString());
             }
             accumulatedData = true;
           }


[05/46] geode git commit: Merge branch 'develop' into feature/GEODE-3071

Posted by zh...@apache.org.
Merge branch 'develop' into feature/GEODE-3071


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

Branch: refs/heads/feature/GEM-1483
Commit: dba7dcd3042ae7cf9776822bb4e69f47291fc296
Parents: 07e8986 78f08e8
Author: Jens Deppe <jd...@pivotal.io>
Authored: Mon Jun 19 08:23:24 2017 -0700
Committer: Jens Deppe <jd...@pivotal.io>
Committed: Mon Jun 19 08:23:24 2017 -0700

----------------------------------------------------------------------
 .../cli/commands/StatusLocatorRealGfshTest.java |  50 +++
 ...erConfigurationServiceEndToEndDUnitTest.java |   8 +-
 .../geode/test/dunit/rules/gfsh/GfshRule.java   | 116 ++++++
 .../geode/test/dunit/rules/gfsh/GfshScript.java | 124 ++++++
 .../source/subnavs/geode-subnav.erb             |   8 +-
 geode-core/build.gradle                         |   4 -
 .../internal/InternalDistributedSystem.java     |  62 +--
 .../apache/geode/internal/cache/EventID.java    |   2 +-
 .../geode/internal/cache/GemFireCacheImpl.java  |   2 -
 .../geode/internal/jta/GlobalTransaction.java   |   4 +
 .../geode/internal/jta/TransactionImpl.java     |   3 +
 .../internal/jta/TransactionManagerImpl.java    |  15 +
 .../geode/internal/jta/UserTransactionImpl.java |   4 +
 .../org/apache/geode/internal/jta/XidImpl.java  |   4 +
 .../internal/security/CallbackInstantiator.java |  28 ++
 .../security/CustomSecurityService.java         | 346 ----------------
 .../security/DisabledSecurityService.java       | 221 -----------
 .../security/EnabledSecurityService.java        | 393 -------------------
 .../security/IntegratedSecurityService.java     | 374 ++++++++++++++++++
 .../security/LegacySecurityService.java         | 186 +--------
 .../internal/security/SecurityService.java      |  99 +++--
 .../security/SecurityServiceFactory.java        | 188 +++------
 .../internal/security/SecurityServiceType.java  |  28 --
 .../security/shiro/ConfigInitializer.java       |  43 --
 .../security/shiro/CustomAuthRealm.java         |  19 +-
 .../security/shiro/RealmInitializer.java        |  54 ---
 .../security/shiro/SecurityManagerProvider.java |  83 ++++
 .../internal/cli/commands/ConfigCommands.java   |  17 +-
 .../CreateAlterDestroyRegionCommands.java       |  24 +-
 .../internal/cli/commands/DataCommands.java     |   4 +-
 .../internal/cli/commands/DeployCommands.java   |  57 +--
 .../cli/commands/DiskStoreCommands.java         |  12 +-
 .../cli/commands/DurableClientCommands.java     |  22 +-
 .../cli/commands/ExportLogsCommand.java         |   4 +-
 .../internal/cli/commands/FunctionCommands.java |  20 +-
 .../internal/cli/commands/IndexCommands.java    |  14 +-
 .../cli/commands/LauncherLifecycleCommands.java |   4 +-
 .../internal/cli/commands/MemberCommands.java   |   4 +-
 .../cli/commands/MiscellaneousCommands.java     |  34 +-
 .../internal/cli/commands/QueueCommands.java    |   2 +-
 .../internal/cli/commands/RegionCommands.java   |   6 +-
 .../internal/cli/commands/WanCommands.java      | 116 +++---
 .../internal/cli/functions/DeployFunction.java  |   3 -
 .../cli/functions/UndeployFunction.java         |   9 +-
 .../internal/cli/i18n/CliStrings.java           |  99 +----
 .../controllers/ConfigCommandsController.java   |  24 +-
 .../web/controllers/DataCommandsController.java |   4 +-
 .../controllers/DeployCommandsController.java   |  26 +-
 .../DiskStoreCommandsController.java            |  22 +-
 .../DurableClientCommandsController.java        |  50 +--
 .../web/controllers/ExportLogController.java    |  10 +-
 .../controllers/FunctionCommandsController.java |  32 +-
 .../controllers/IndexCommandsController.java    |  36 +-
 .../controllers/MemberCommandsController.java   |   6 +-
 .../MiscellaneousCommandsController.java        |  36 +-
 .../controllers/QueueCommandsController.java    |   6 +-
 .../controllers/RegionCommandsController.java   |  20 +-
 .../web/controllers/WanCommandsController.java  | 143 +++----
 .../internal/index/HashIndexSetJUnitTest.java   |   2 +-
 .../membership/MembershipJUnitTest.java         |   3 -
 .../messenger/JGroupsMessengerJUnitTest.java    |   6 +-
 .../gms/mgr/GMSMembershipManagerJUnitTest.java  |   8 +-
 .../DeposePrimaryBucketMessageTest.java         |   1 -
 .../partitioned/FetchEntryMessageTest.java      |   1 -
 .../FetchPartitionDetailsMessageTest.java       |   1 -
 .../partitioned/MoveBucketMessageTest.java      |   1 -
 .../partitioned/RemoveBucketMessageTest.java    |   1 -
 .../sockets/ClientServerMiscBCDUnitTest.java    |  42 ++
 .../tier/sockets/ClientServerMiscDUnitTest.java |   4 +-
 .../tier/sockets/command/ContainsKey66Test.java |   2 +-
 .../tier/sockets/command/CreateRegionTest.java  |   2 +-
 .../tier/sockets/command/Destroy65Test.java     |   2 +-
 .../tier/sockets/command/DestroyRegionTest.java |   2 +-
 .../cache/tier/sockets/command/DestroyTest.java |   2 +-
 .../sockets/command/ExecuteFunction65Test.java  |   2 +-
 .../sockets/command/ExecuteFunction66Test.java  |   2 +-
 .../sockets/command/ExecuteFunctionTest.java    |   2 +-
 .../cache/tier/sockets/command/Get70Test.java   |   2 +-
 .../tier/sockets/command/GetAll651Test.java     |   2 +-
 .../tier/sockets/command/GetAll70Test.java      |   2 +-
 .../cache/tier/sockets/command/GetAllTest.java  |   2 +-
 .../sockets/command/GetAllWithCallbackTest.java |   2 +-
 .../tier/sockets/command/InvalidateTest.java    |   2 +-
 .../cache/tier/sockets/command/KeySetTest.java  |   2 +-
 .../cache/tier/sockets/command/Put61Test.java   |  30 +-
 .../cache/tier/sockets/command/Put65Test.java   |  28 +-
 .../cache/tier/sockets/command/PutTest.java     |  34 +-
 .../sockets/command/RegisterInterest61Test.java |   2 +-
 .../command/RegisterInterestList61Test.java     |   2 +-
 .../command/RegisterInterestList66Test.java     |   2 +-
 .../command/RegisterInterestListTest.java       |   2 +-
 .../sockets/command/RegisterInterestTest.java   |   2 +-
 .../tier/sockets/command/RemoveAllTest.java     |   2 +-
 .../cache/tier/sockets/command/RequestTest.java |   2 +-
 .../sockets/command/UnregisterInterestTest.java |   2 +-
 .../cache/wan/serial/DestroyMessageTest.java    |   1 -
 .../xmlcache/DefaultEntityResolver2Test.java    |   1 -
 .../logging/log4j/FastLoggerJUnitTest.java      |   3 +-
 .../security/DisabledSecurityServiceTest.java   | 164 --------
 .../security/EnabledSecurityServiceTest.java    | 184 ---------
 .../internal/security/FakePostProcessor.java    | 103 -----
 .../internal/security/FakeSecurityManager.java  | 103 -----
 ...ntegratedSecurityServiceConstructorTest.java |  93 +++++
 .../security/IntegratedSecurityServiceTest.java | 166 ++++++++
 .../security/LegacySecurityServiceTest.java     |  58 +++
 ...urityServiceFactoryShiroIntegrationTest.java |  38 +-
 .../security/SecurityServiceFactoryTest.java    | 314 ++++++---------
 .../internal/security/SecurityServiceTest.java  |  21 +-
 .../shiro/ConfigInitializerIntegrationTest.java |  91 -----
 .../internal/statistics/StatisticsImplTest.java |  61 +--
 .../geode/internal/tcp/ConnectionJUnitTest.java |   2 +-
 .../internal/CompositeBuilderViaFromTest.java   |   1 -
 .../internal/CompositeBuilderViaProxyTest.java  |   1 -
 .../beans/DistributedSystemBridgeJUnitTest.java |   2 +-
 .../cli/GfshParserAutoCompletionTest.java       |   6 +-
 .../cli/commands/ConfigCommandsDUnitTest.java   |   4 +-
 ...eateAlterDestroyRegionCommandsDUnitTest.java |  26 +-
 .../cli/commands/DeployCommandsDUnitTest.java   |  36 +-
 .../commands/DiskStoreCommandsDUnitTest.java    |  16 +-
 .../commands/GemfireDataCommandsDUnitTest.java  |  60 ++-
 .../cli/commands/IndexCommandsDUnitTest.java    |  16 +-
 .../ListAndDescribeRegionDUnitTest.java         |   8 +-
 .../cli/commands/MemberCommandsDUnitTest.java   |   2 +-
 .../MiscellaneousCommandsDUnitTest.java         |  17 +-
 .../cli/commands/QueueCommandsDUnitTest.java    |   6 +-
 .../cli/commands/ShowMetricsDUnitTest.java      |   6 +-
 .../cli/commands/ShowStackTraceDUnitTest.java   |   8 +-
 .../cli/shell/GfshMultilineCommandTest.java     |   7 +-
 .../ClusterConfigDistributionDUnitTest.java     |   2 +-
 ...tyServiceWithCustomRealmIntegrationTest.java |   2 +-
 ...urityServiceWithShiroIniIntegrationTest.java |   2 +-
 .../WanCommandsControllerJUnitTest.java         |  14 +-
 .../executor/AbstractScanExecutorTest.java      |   1 -
 .../CacheFactoryWithSecurityObjectTest.java     |  68 +++-
 ...SecurityManagerLifecycleDistributedTest.java |   4 +-
 .../transactions/JTA_transactions.html.md.erb   |  22 +-
 geode-docs/rest_apps/setup_config.html.md.erb   | 269 ++++++++-----
 .../tools_modules/gfsh/tour_of_gfsh.html.md.erb |  86 ++--
 .../lucene/internal/LuceneIndexFactorySpy.java  |   3 +-
 .../PartitionedRepositoryManagerJUnitTest.java  |   2 +-
 .../LuceneClusterConfigurationDUnitTest.java    |   4 +-
 .../LuceneQueryFunctionJUnitTest.java           |  12 +-
 .../TopEntriesFunctionCollectorJUnitTest.java   |   4 +-
 .../cache/lucene/test/IndexRepositorySpy.java   |   2 +-
 geode-pulse/build.gradle                        |   3 -
 .../apache/geode/tools/pulse/tests/Server.java  |  19 +-
 .../tools/pulse/tests/rules/ServerRule.java     |   6 +-
 ...mandCreateDestroyGatewaySenderDUnitTest.java |  56 +--
 ...anCommandCreateGatewayReceiverDUnitTest.java |  57 ++-
 ...WanCommandGatewayReceiverStartDUnitTest.java |  39 +-
 .../WanCommandGatewayReceiverStopDUnitTest.java |  39 +-
 .../WanCommandGatewaySenderStartDUnitTest.java  |  40 +-
 .../WanCommandGatewaySenderStopDUnitTest.java   |  34 +-
 .../wan/wancommand/WanCommandListDUnitTest.java |  32 +-
 .../WanCommandPauseResumeDUnitTest.java         |  68 ++--
 .../wancommand/WanCommandStatusDUnitTest.java   |  56 ++-
 .../ClusterConfigurationDUnitTest.java          |  10 +-
 ...nfigurationIndexWithFromClauseDUnitTest.java |   4 +-
 gradle/dependency-versions.properties           |   4 +-
 gradle/test.gradle                              |   7 +-
 160 files changed, 2604 insertions(+), 3534 deletions(-)
----------------------------------------------------------------------



[12/46] geode git commit: GEODE-3091: remove empty method

Posted by zh...@apache.org.
GEODE-3091: remove empty method

This closes #585


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

Branch: refs/heads/feature/GEM-1483
Commit: d8160d6e644976e88fa32b08993c3cc6574143c8
Parents: 80667f3
Author: Nick Reich <nr...@pivotal.io>
Authored: Thu Jun 15 15:59:50 2017 -0700
Committer: Anil <ag...@pivotal.io>
Committed: Mon Jun 19 15:00:23 2017 -0700

----------------------------------------------------------------------
 .../geode/internal/cache/DistributedRegion.java      |  1 -
 .../org/apache/geode/internal/cache/LocalRegion.java | 15 ---------------
 .../geode/internal/cache/PartitionedRegion.java      |  1 -
 3 files changed, 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/d8160d6e/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
index 9df64d0..21f911d 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java
@@ -935,7 +935,6 @@ public class DistributedRegion extends LocalRegion implements CacheDistributionA
   public void invalidate(Object key, Object aCallbackArgument)
       throws TimeoutException, EntryNotFoundException {
     validateKey(key);
-    validateCallbackArg(aCallbackArgument);
     checkReadiness();
     checkForLimitedOrNoAccess();
     Lock dlock = this.getDistributedLockIfGlobal(key);

http://git-wip-us.apache.org/repos/asf/geode/blob/d8160d6e/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
index 2b45a54..02625ee 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
@@ -1120,7 +1120,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
   @Retained
   EntryEventImpl newDestroyEntryEvent(Object key, Object aCallbackArgument) {
     validateKey(key);
-    validateCallbackArg(aCallbackArgument);
     checkReadiness();
     checkForLimitedOrNoAccess();
 
@@ -1349,7 +1348,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
       boolean retainResult) throws TimeoutException, CacheLoaderException {
     assert !retainResult || preferCD;
     validateKey(key);
-    validateCallbackArg(aCallbackArgument);
     checkReadiness();
     checkForNoAccess();
     discoverJTA();
@@ -1563,7 +1561,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
   @Override
   public void invalidateRegion(Object aCallbackArgument) throws TimeoutException {
     getDataView().checkSupportsRegionInvalidate();
-    validateCallbackArg(aCallbackArgument);
     checkReadiness();
     checkForLimitedOrNoAccess();
     RegionEventImpl event = new RegionEventImpl(this, Operation.REGION_INVALIDATE,
@@ -3118,8 +3115,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
   protected void validateArguments(Object key, Object value, Object aCallbackArgument) {
     validateKey(key);
     validateValue(value);
-    validateCallbackArg(aCallbackArgument);
-
   }
 
   void validateKey(Object key) {
@@ -3142,15 +3137,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
   }
 
   /**
-   * Starting in 3.5, we don't check to see if the callback argument is {@code Serializable}. We
-   * instead rely on the actual serialization (which happens in-thread with the put) to tell us if
-   * there are any problems. TODO: delete method validateCallbackArg
-   */
-  void validateCallbackArg(Object aCallbackArgument) {
-    // do nothing
-  }
-
-  /**
    * @since GemFire 5.0.2
    */
   private final boolean doExpensiveValidations =
@@ -11633,7 +11619,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
   public boolean remove(Object key, Object value, Object callbackArg) {
     checkIfConcurrentMapOpsAllowed();
     validateKey(key);
-    validateCallbackArg(callbackArg);
     checkReadiness();
     checkForLimitedOrNoAccess();
 

http://git-wip-us.apache.org/repos/asf/geode/blob/d8160d6e/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
index 288f4a9..cf3ca76 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java
@@ -3082,7 +3082,6 @@ public class PartitionedRegion extends LocalRegion
       EntryEventImpl clientEvent, boolean returnTombstones)
       throws TimeoutException, CacheLoaderException {
     validateKey(key);
-    validateCallbackArg(aCallbackArgument);
     checkReadiness();
     checkForNoAccess();
     discoverJTA();


[03/46] geode git commit: GEODE_3071: Add Apache license header

Posted by zh...@apache.org.
GEODE_3071: Add Apache license header


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

Branch: refs/heads/feature/GEM-1483
Commit: b26fa518c8ab04f60697a5b61c36a1222a68b515
Parents: ee88cd2
Author: Jens Deppe <jd...@pivotal.io>
Authored: Fri Jun 16 08:05:32 2017 -0700
Committer: Jens Deppe <jd...@pivotal.io>
Committed: Fri Jun 16 08:05:32 2017 -0700

----------------------------------------------------------------------
 gradle/docker.gradle | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/b26fa518/gradle/docker.gradle
----------------------------------------------------------------------
diff --git a/gradle/docker.gradle b/gradle/docker.gradle
index 5c2ef77..b67c073 100644
--- a/gradle/docker.gradle
+++ b/gradle/docker.gradle
@@ -1,4 +1,21 @@
 /*
+ * 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.
+ */
+
+/*
  * Configuration for running (dunit) tests in parallel in Docker containers.
  * The container used must hava JAVA_HOME set in it's environment and must
  * have 'java' defined on the path. For example, the relevant Dockerfile


[39/46] geode git commit: GEODE-2995: Implementing review feedback

Posted by zh...@apache.org.
GEODE-2995: Implementing review feedback

Numerous tweaks and fixes
Created protobuf package under org.apache.geode.protocol and moved several classes
Added javadoc comments

Signed-off-by: Galen O'Sullivan <go...@pivotal.io>


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

Branch: refs/heads/feature/GEM-1483
Commit: 31f4de065bd32b5801017427a14cec142c5897fc
Parents: c71c28d
Author: Brian Rowe <br...@pivotal.io>
Authored: Tue Jun 20 15:49:11 2017 -0700
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Mon Jun 26 09:26:22 2017 -0700

----------------------------------------------------------------------
 geode-protobuf/build.gradle                     |  2 -
 .../org/apache/geode/ProtobufUtilities.java     | 34 --------
 .../org/apache/geode/protocol/OpsProcessor.java | 53 ------------
 .../InvalidProtocolMessageException.java        |  3 +
 .../handler/ProtobufStreamProcessor.java        | 61 --------------
 .../geode/protocol/handler/ProtocolHandler.java | 27 ------
 .../protobuf/ProtobufProtocolHandler.java       | 41 ---------
 .../protocol/operations/OperationHandler.java   | 10 +++
 .../ProtobufRequestOperationParser.java         | 33 --------
 .../protobuf/GetRequestOperationHandler.java    | 59 -------------
 .../registry/OperationsHandlerRegistry.java     |  3 +
 ...rationHandlerAlreadyRegisteredException.java |  3 +
 .../OperationHandlerNotRegisteredException.java |  3 +
 .../protobuf/EncodingTypeTranslator.java        | 86 +++++++++++++++++++
 .../protocol/protobuf/ProtobufOpsProcessor.java | 66 +++++++++++++++
 .../protobuf/ProtobufSerializationService.java  | 51 ++++++++++++
 .../protobuf/ProtobufStreamProcessor.java       | 60 +++++++++++++
 .../protocol/protobuf/ProtobufUtilities.java    | 34 ++++++++
 .../operations/GetRequestOperationHandler.java  | 58 +++++++++++++
 .../serializer/ProtobufProtocolSerializer.java  | 41 +++++++++
 .../protocol/serializer/ProtocolSerializer.java | 31 +++++++
 .../ProtobufSerializationService.java           | 50 -----------
 .../UnsupportedEncodingTypeException.java       |  3 +
 .../translation/EncodingTypeTranslator.java     | 83 ------------------
 .../UnsupportedEncodingTypeException.java       | 21 -----
 .../CodecAlreadyRegisteredForTypeException.java |  3 +
 .../CodecNotRegisteredForTypeException.java     |  3 +
 ...pache.geode.protocol.handler.ProtocolHandler |  1 -
 ...e.geode.protocol.operations.OperationHandler |  2 +-
 ...geode.protocol.serializer.ProtocolSerializer |  1 +
 .../geode/client/protocol/IntegrationTest.java  | 32 +++----
 .../geode/client/protocol/OpsProcessorTest.java | 64 --------------
 .../ProtobufProtocolHandlerJUnitTest.java       | 88 --------------------
 .../GetRequestOperationHandlerTest.java         |  4 +-
 .../protobuf/ProtobufOpsProcessorTest.java      | 62 ++++++++++++++
 .../ProtobufProtocolSerializerJUnitTest.java    | 81 ++++++++++++++++++
 .../ProtobufSerializationServiceImplTest.java   |  5 +-
 ...eToSerializationTypeTranslatorJUnitTest.java |  1 +
 .../registry/CodecRegistryJUnitTest.java        | 16 ++--
 39 files changed, 632 insertions(+), 647 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/build.gradle
----------------------------------------------------------------------
diff --git a/geode-protobuf/build.gradle b/geode-protobuf/build.gradle
index 2102f6a..f069267 100644
--- a/geode-protobuf/build.gradle
+++ b/geode-protobuf/build.gradle
@@ -44,13 +44,11 @@ protobuf {
         // The artifact spec for the Protobuf Compiler
         artifact = 'com.google.protobuf:protoc:3.0.0'
     }
-    // this allows our spotless rule to skip this directory (hopefully rat too)
     generatedFilesBaseDir = "$buildDir/generated-src/proto"
 }
 
 sourceSets {
     main {
-
         java {
             srcDir 'build/generated-src/proto/main/java'
         }

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/ProtobufUtilities.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/ProtobufUtilities.java b/geode-protobuf/src/main/java/org/apache/geode/ProtobufUtilities.java
deleted file mode 100644
index c25fc14..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/ProtobufUtilities.java
+++ /dev/null
@@ -1,34 +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;
-
-import com.google.protobuf.ByteString;
-
-import org.apache.geode.protocol.protobuf.BasicTypes;
-import org.apache.geode.protocol.protobuf.ClientProtocol;
-
-public abstract class ProtobufUtilities {
-  public static BasicTypes.EncodedValue getEncodedValue(BasicTypes.EncodingType resultEncodingType,
-      byte[] resultEncodedValue) {
-    return BasicTypes.EncodedValue.newBuilder().setEncodingType(resultEncodingType)
-        .setValue(ByteString.copyFrom(resultEncodedValue)).build();
-  }
-
-  public static ClientProtocol.Message wrapResponseWithDefaultHeader(
-      ClientProtocol.Response response) {
-    return ClientProtocol.Message.newBuilder()
-        .setMessageHeader(ClientProtocol.MessageHeader.newBuilder()).setResponse(response).build();
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/OpsProcessor.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/OpsProcessor.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/OpsProcessor.java
deleted file mode 100644
index 999fdf0..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/OpsProcessor.java
+++ /dev/null
@@ -1,53 +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.protocol;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.protocol.operations.OperationHandler;
-import org.apache.geode.protocol.operations.ProtobufRequestOperationParser;
-import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry;
-import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException;
-import org.apache.geode.protocol.protobuf.ClientProtocol;
-import org.apache.geode.protocol.protobuf.RegionAPI;
-import org.apache.geode.serialization.SerializationService;
-import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
-import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
-
-public class OpsProcessor {
-  private final OperationsHandlerRegistry opsHandlerRegistry;
-  private final SerializationService serializationService;
-
-  public OpsProcessor(OperationsHandlerRegistry opsHandlerRegistry,
-      SerializationService serializationService) {
-    this.opsHandlerRegistry = opsHandlerRegistry;
-    this.serializationService = serializationService;
-  }
-
-  public ClientProtocol.Response process(ClientProtocol.Request request, Cache cache)
-      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
-    OperationHandler opsHandler = null;
-    try {
-      opsHandler = opsHandlerRegistry
-          .getOperationHandlerForOperationId(request.getRequestAPICase().getNumber());
-    } catch (OperationHandlerNotRegisteredException e) {
-      e.printStackTrace();
-    }
-
-    Object responseMessage = opsHandler.process(serializationService,
-        ProtobufRequestOperationParser.getRequestForOperationTypeID(request), cache);
-    return ClientProtocol.Response.newBuilder()
-        .setGetResponse((RegionAPI.GetResponse) responseMessage).build();
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/exception/InvalidProtocolMessageException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/exception/InvalidProtocolMessageException.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/exception/InvalidProtocolMessageException.java
index 8f73f57..dae03a1 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/exception/InvalidProtocolMessageException.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/exception/InvalidProtocolMessageException.java
@@ -14,6 +14,9 @@
  */
 package org.apache.geode.protocol.exception;
 
+/**
+ * Indicates that a message didn't properly follow it's protocol specification.
+ */
 public class InvalidProtocolMessageException extends Exception {
   public InvalidProtocolMessageException(String message) {
     super(message);

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/ProtobufStreamProcessor.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/ProtobufStreamProcessor.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/ProtobufStreamProcessor.java
deleted file mode 100644
index e459f76..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/ProtobufStreamProcessor.java
+++ /dev/null
@@ -1,61 +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.protocol.handler;
-
-import org.apache.geode.ProtobufUtilities;
-import org.apache.geode.cache.Cache;
-import org.apache.geode.protocol.OpsProcessor;
-import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
-import org.apache.geode.protocol.handler.protobuf.ProtobufProtocolHandler;
-import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry;
-import org.apache.geode.protocol.operations.registry.exception.OperationHandlerAlreadyRegisteredException;
-import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException;
-import org.apache.geode.protocol.protobuf.ClientProtocol;
-import org.apache.geode.serialization.ProtobufSerializationService;
-import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
-import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
-import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-public class ProtobufStreamProcessor {
-  ProtobufProtocolHandler protobufProtocolHandler;
-  OperationsHandlerRegistry registry;
-  ProtobufSerializationService protobufSerializationService;
-  OpsProcessor opsProcessor;
-
-  public ProtobufStreamProcessor()
-      throws OperationHandlerAlreadyRegisteredException, CodecAlreadyRegisteredForTypeException {
-    protobufProtocolHandler = new ProtobufProtocolHandler();
-    registry = new OperationsHandlerRegistry();
-    protobufSerializationService = new ProtobufSerializationService();
-    opsProcessor = new OpsProcessor(registry, protobufSerializationService);
-  }
-
-  public void processOneMessage(InputStream inputStream, OutputStream outputStream, Cache cache)
-      throws InvalidProtocolMessageException, OperationHandlerNotRegisteredException,
-      UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException, IOException {
-    ClientProtocol.Message message = protobufProtocolHandler.deserialize(inputStream);
-
-    ClientProtocol.Request request = message.getRequest();
-    ClientProtocol.Response response = opsProcessor.process(request, cache);
-
-    ClientProtocol.Message responseMessage =
-        ProtobufUtilities.wrapResponseWithDefaultHeader(response);
-    protobufProtocolHandler.serialize(responseMessage, outputStream);
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/ProtocolHandler.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/ProtocolHandler.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/ProtocolHandler.java
deleted file mode 100644
index 4947a0a..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/ProtocolHandler.java
+++ /dev/null
@@ -1,27 +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.protocol.handler;
-
-import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-public interface ProtocolHandler<T> {
-  T deserialize(InputStream inputStream) throws InvalidProtocolMessageException;
-
-  void serialize(T inputMessage, OutputStream outputStream) throws IOException;
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/protobuf/ProtobufProtocolHandler.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/protobuf/ProtobufProtocolHandler.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/protobuf/ProtobufProtocolHandler.java
deleted file mode 100644
index f8c2abd..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/handler/protobuf/ProtobufProtocolHandler.java
+++ /dev/null
@@ -1,41 +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.protocol.handler.protobuf;
-
-import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
-import org.apache.geode.protocol.handler.ProtocolHandler;
-import org.apache.geode.protocol.protobuf.ClientProtocol;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-public class ProtobufProtocolHandler implements ProtocolHandler<ClientProtocol.Message> {
-  @Override
-  public ClientProtocol.Message deserialize(InputStream inputStream)
-      throws InvalidProtocolMessageException {
-    try {
-      return ClientProtocol.Message.parseDelimitedFrom(inputStream);
-    } catch (IOException e) {
-      throw new InvalidProtocolMessageException("Failed to parse Protobuf Message", e);
-    }
-  }
-
-  @Override
-  public void serialize(ClientProtocol.Message inputMessage, OutputStream outputStream)
-      throws IOException {
-    inputMessage.writeDelimitedTo(outputStream);
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/OperationHandler.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/OperationHandler.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/OperationHandler.java
index 020c27b..8eab146 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/OperationHandler.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/OperationHandler.java
@@ -15,13 +15,23 @@
 package org.apache.geode.protocol.operations;
 
 import org.apache.geode.cache.Cache;
+import org.apache.geode.protocol.protobuf.ProtobufOpsProcessor;
+import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry;
 import org.apache.geode.serialization.SerializationService;
 import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
 import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
 
+/**
+ * This interface is implemented by a object capable of handling request types 'Req' and returning an a response of type 'Resp'
+ *
+ * See {@link ProtobufOpsProcessor}
+ */
 public interface OperationHandler<Req, Resp> {
   Resp process(SerializationService serializationService, Req request, Cache cache)
       throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException;
 
+  /**
+   * @return the magic number used for registering the operation type with the {@link OperationsHandlerRegistry}.
+   */
   int getOperationCode();
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/ProtobufRequestOperationParser.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/ProtobufRequestOperationParser.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/ProtobufRequestOperationParser.java
deleted file mode 100644
index 7fb0eab..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/ProtobufRequestOperationParser.java
+++ /dev/null
@@ -1,33 +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.protocol.operations;
-
-import org.apache.geode.protocol.protobuf.ClientProtocol;
-
-public class ProtobufRequestOperationParser {
-  public static Object getRequestForOperationTypeID(ClientProtocol.Request request) {
-    switch (request.getRequestAPICase()) {
-      case PUTREQUEST:
-        return request.getPutRequest();
-      case GETREQUEST:
-        return request.getGetRequest();
-      case PUTALLREQUEST:
-        return request.getPutAllRequest();
-      default:
-        throw new RuntimeException(
-            "Unknown request type: " + request.getRequestAPICase().getNumber());
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandler.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandler.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandler.java
deleted file mode 100644
index dafacc0..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandler.java
+++ /dev/null
@@ -1,59 +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.protocol.operations.protobuf;
-
-import org.apache.geode.ProtobufUtilities;
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionService;
-import org.apache.geode.protocol.operations.OperationHandler;
-import org.apache.geode.protocol.protobuf.BasicTypes;
-import org.apache.geode.protocol.protobuf.ClientProtocol;
-import org.apache.geode.protocol.protobuf.RegionAPI;
-import org.apache.geode.serialization.SerializationService;
-import org.apache.geode.serialization.protobuf.translation.EncodingTypeTranslator;
-import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
-import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
-
-public class GetRequestOperationHandler
-    implements OperationHandler<RegionAPI.GetRequest, RegionAPI.GetResponse> {
-
-  @Override
-  public RegionAPI.GetResponse process(SerializationService serializationService,
-      RegionAPI.GetRequest request, Cache cache)
-      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
-    String regionName = request.getRegionName();
-    BasicTypes.EncodedValue key = request.getKey();
-    BasicTypes.EncodingType encodingType = key.getEncodingType();
-    byte[] value = key.getValue().toByteArray();
-    Object decodedValue = serializationService.decode(encodingType, value);
-
-    Region region = cache.getRegion(regionName);
-    Object resultValue = region.get(decodedValue);
-
-    BasicTypes.EncodingType resultEncodingType =
-        EncodingTypeTranslator.getEncodingTypeForObject(resultValue);
-    byte[] resultEncodedValue = serializationService.encode(resultEncodingType, resultValue);
-
-    return RegionAPI.GetResponse.newBuilder()
-        .setResult(ProtobufUtilities.getEncodedValue(resultEncodingType, resultEncodedValue))
-        .build();
-  }
-
-  @Override
-  public int getOperationCode() {
-    return ClientProtocol.Request.RequestAPICase.GETREQUEST.getNumber();
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/OperationsHandlerRegistry.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/OperationsHandlerRegistry.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/OperationsHandlerRegistry.java
index 80e0459..8e3a331 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/OperationsHandlerRegistry.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/OperationsHandlerRegistry.java
@@ -21,6 +21,9 @@ import org.apache.geode.protocol.operations.registry.exception.OperationHandlerN
 import java.util.HashMap;
 import java.util.ServiceLoader;
 
+/**
+ * This class tracks which operation handlers are expected to handle which types of operations.
+ */
 public class OperationsHandlerRegistry {
   private HashMap<Integer, OperationHandler> registeredOperations = new HashMap<>();
 

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerAlreadyRegisteredException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerAlreadyRegisteredException.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerAlreadyRegisteredException.java
index 1f42c10..519698d 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerAlreadyRegisteredException.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerAlreadyRegisteredException.java
@@ -14,6 +14,9 @@
  */
 package org.apache.geode.protocol.operations.registry.exception;
 
+/**
+ * Indicates that an operation handler is attempting to register for an already handled operation type.
+ */
 public class OperationHandlerAlreadyRegisteredException extends Exception {
   public OperationHandlerAlreadyRegisteredException(String message) {
     super(message);

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerNotRegisteredException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerNotRegisteredException.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerNotRegisteredException.java
index f83e1b3..6772e56 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerNotRegisteredException.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/registry/exception/OperationHandlerNotRegisteredException.java
@@ -14,6 +14,9 @@
  */
 package org.apache.geode.protocol.operations.registry.exception;
 
+/**
+ * Indicates that we're trying to handle an operation for which no operation handler has registered.
+ */
 public class OperationHandlerNotRegisteredException extends Exception {
   public OperationHandlerNotRegisteredException(String message) {
     super(message);

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/EncodingTypeTranslator.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/EncodingTypeTranslator.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/EncodingTypeTranslator.java
new file mode 100644
index 0000000..650ac81
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/EncodingTypeTranslator.java
@@ -0,0 +1,86 @@
+/*
+ * 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.protocol.protobuf;
+
+import org.apache.geode.pdx.JSONFormatter;
+import org.apache.geode.pdx.PdxInstance;
+import org.apache.geode.protocol.protobuf.BasicTypes;
+import org.apache.geode.serialization.SerializationType;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+
+/**
+ * This class maps protobuf specific encoding types and the corresponding serialization types.
+ */
+public abstract class EncodingTypeTranslator {
+  public static SerializationType getSerializationTypeForEncodingType(
+      BasicTypes.EncodingType encodingType) throws UnsupportedEncodingTypeException {
+    switch (encodingType) {
+      case INT:
+        return SerializationType.INT;
+      case BYTE:
+        return SerializationType.BYTE;
+      case JSON:
+        return SerializationType.JSON;
+      case LONG:
+        return SerializationType.LONG;
+      case FLOAT:
+        return SerializationType.FLOAT;
+      case SHORT:
+        return SerializationType.SHORT;
+      case BINARY:
+        return SerializationType.BINARY;
+      case DOUBLE:
+        return SerializationType.DOUBLE;
+      case STRING:
+        return SerializationType.STRING;
+      case BOOLEAN:
+        return SerializationType.BOOLEAN;
+      default:
+        throw new UnsupportedEncodingTypeException(
+            "No serialization type found for protobuf encoding type: " + encodingType);
+    }
+  }
+
+  public static BasicTypes.EncodingType getEncodingTypeForObject(Object resultValue)
+      throws UnsupportedEncodingTypeException {
+    if (resultValue instanceof Integer) {
+      return BasicTypes.EncodingType.INT;
+    } else if (resultValue instanceof Byte) {
+      return BasicTypes.EncodingType.BYTE;
+    } else if (resultValue instanceof PdxInstance) {
+      String pdxClassName = ((PdxInstance) resultValue).getClassName();
+      if (pdxClassName.equals(JSONFormatter.JSON_CLASSNAME)) {
+        return BasicTypes.EncodingType.JSON;
+      }
+    } else if (resultValue instanceof Long) {
+      return BasicTypes.EncodingType.LONG;
+    } else if (resultValue instanceof Float) {
+      return BasicTypes.EncodingType.FLOAT;
+    } else if (resultValue instanceof Short) {
+      return BasicTypes.EncodingType.SHORT;
+    } else if (resultValue instanceof byte[]) {
+      return BasicTypes.EncodingType.BINARY;
+    } else if (resultValue instanceof Double) {
+      return BasicTypes.EncodingType.DOUBLE;
+    } else if (resultValue instanceof String) {
+      return BasicTypes.EncodingType.STRING;
+    } else if (resultValue instanceof Boolean) {
+      return BasicTypes.EncodingType.BOOLEAN;
+    }
+
+    throw new UnsupportedEncodingTypeException(
+        "We cannot translate: " + resultValue.getClass() + " into a specific Protobuf Encoding");
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessor.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessor.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessor.java
new file mode 100644
index 0000000..c572d80
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessor.java
@@ -0,0 +1,66 @@
+/*
+ * 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.protocol.protobuf;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
+import org.apache.geode.protocol.operations.OperationHandler;
+import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry;
+import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException;
+import org.apache.geode.serialization.SerializationService;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+
+/**
+ * This handles protobuf requests by determining the operation type of the request and dispatching it to the appropriate handler.
+ */
+public class ProtobufOpsProcessor {
+  private final OperationsHandlerRegistry opsHandlerRegistry;
+  private final SerializationService serializationService;
+
+  public ProtobufOpsProcessor(OperationsHandlerRegistry opsHandlerRegistry,
+                              SerializationService serializationService) {
+    this.opsHandlerRegistry = opsHandlerRegistry;
+    this.serializationService = serializationService;
+  }
+
+  public ClientProtocol.Response process(ClientProtocol.Request request, Cache cache)
+    throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException,
+    OperationHandlerNotRegisteredException, InvalidProtocolMessageException {
+    OperationHandler opsHandler = opsHandlerRegistry
+      .getOperationHandlerForOperationId(request.getRequestAPICase().getNumber());
+
+    Object responseMessage = opsHandler.process(serializationService,
+        getRequestForOperationTypeID(request), cache);
+    return ClientProtocol.Response.newBuilder()
+        .setGetResponse((RegionAPI.GetResponse) responseMessage).build();
+  }
+
+  // package visibility for testing
+  static Object getRequestForOperationTypeID(ClientProtocol.Request request)
+    throws InvalidProtocolMessageException {
+    switch (request.getRequestAPICase()) {
+      case PUTREQUEST:
+        return request.getPutRequest();
+      case GETREQUEST:
+        return request.getGetRequest();
+      case PUTALLREQUEST:
+        return request.getPutAllRequest();
+      default:
+        throw new InvalidProtocolMessageException(
+          "Unknown request type: " + request.getRequestAPICase().getNumber());
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufSerializationService.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufSerializationService.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufSerializationService.java
new file mode 100644
index 0000000..fc76d5e
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufSerializationService.java
@@ -0,0 +1,51 @@
+/*
+ * 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.protocol.protobuf;
+
+import org.apache.geode.serialization.SerializationService;
+import org.apache.geode.serialization.SerializationType;
+import org.apache.geode.serialization.TypeCodec;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.SerializationCodecRegistry;
+import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+
+public class ProtobufSerializationService implements SerializationService<BasicTypes.EncodingType> {
+  private SerializationCodecRegistry serializationCodecRegistry = new SerializationCodecRegistry();
+
+  public ProtobufSerializationService() throws CodecAlreadyRegisteredForTypeException {}
+
+  @Override
+  public byte[] encode(BasicTypes.EncodingType encodingTypeValue, Object value)
+      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
+    TypeCodec codecForType = getTypeCodecForProtobufType(encodingTypeValue);
+    return codecForType.encode(value);
+  }
+
+  @Override
+  public Object decode(BasicTypes.EncodingType encodingTypeValue, byte[] value)
+      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
+    TypeCodec codecForType = getTypeCodecForProtobufType(encodingTypeValue);
+    return codecForType.decode(value);
+  }
+
+  private TypeCodec getTypeCodecForProtobufType(BasicTypes.EncodingType encodingTypeValue)
+      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
+    SerializationType serializationTypeForEncodingType =
+        EncodingTypeTranslator.getSerializationTypeForEncodingType(encodingTypeValue);
+
+    return serializationCodecRegistry.getCodecForType(serializationTypeForEncodingType);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufStreamProcessor.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufStreamProcessor.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufStreamProcessor.java
new file mode 100644
index 0000000..41a3c40
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufStreamProcessor.java
@@ -0,0 +1,60 @@
+/*
+ * 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.protocol.protobuf;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
+import org.apache.geode.protocol.protobuf.serializer.ProtobufProtocolSerializer;
+import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry;
+import org.apache.geode.protocol.operations.registry.exception.OperationHandlerAlreadyRegisteredException;
+import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * This object handles an incoming stream containing protobuf messages. It parses the protobuf messages, hands the requests to an appropriate handler, wraps the response in a protobuf message, and then pushes it to the output stream.
+ */
+public class ProtobufStreamProcessor {
+  ProtobufProtocolSerializer protobufProtocolSerializer;
+  OperationsHandlerRegistry registry;
+  ProtobufSerializationService protobufSerializationService;
+  ProtobufOpsProcessor protobufOpsProcessor;
+
+  public ProtobufStreamProcessor()
+      throws OperationHandlerAlreadyRegisteredException, CodecAlreadyRegisteredForTypeException {
+    protobufProtocolSerializer = new ProtobufProtocolSerializer();
+    registry = new OperationsHandlerRegistry();
+    protobufSerializationService = new ProtobufSerializationService();
+    protobufOpsProcessor = new ProtobufOpsProcessor(registry, protobufSerializationService);
+  }
+
+  public void processOneMessage(InputStream inputStream, OutputStream outputStream, Cache cache)
+      throws InvalidProtocolMessageException, OperationHandlerNotRegisteredException,
+      UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException, IOException {
+    ClientProtocol.Message message = protobufProtocolSerializer.deserialize(inputStream);
+
+    ClientProtocol.Request request = message.getRequest();
+    ClientProtocol.Response response = protobufOpsProcessor.process(request, cache);
+
+    ClientProtocol.Message responseMessage =
+        ProtobufUtilities.wrapResponseWithDefaultHeader(response);
+    protobufProtocolSerializer.serialize(responseMessage, outputStream);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufUtilities.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufUtilities.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufUtilities.java
new file mode 100644
index 0000000..d763662
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/ProtobufUtilities.java
@@ -0,0 +1,34 @@
+/*
+ * 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.protocol.protobuf;
+
+import com.google.protobuf.ByteString;
+
+import org.apache.geode.protocol.protobuf.BasicTypes;
+import org.apache.geode.protocol.protobuf.ClientProtocol;
+
+public abstract class ProtobufUtilities {
+  public static BasicTypes.EncodedValue getEncodedValue(BasicTypes.EncodingType resultEncodingType,
+      byte[] resultEncodedValue) {
+    return BasicTypes.EncodedValue.newBuilder().setEncodingType(resultEncodingType)
+        .setValue(ByteString.copyFrom(resultEncodedValue)).build();
+  }
+
+  public static ClientProtocol.Message wrapResponseWithDefaultHeader(
+      ClientProtocol.Response response) {
+    return ClientProtocol.Message.newBuilder()
+        .setMessageHeader(ClientProtocol.MessageHeader.newBuilder()).setResponse(response).build();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandler.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandler.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandler.java
new file mode 100644
index 0000000..37d1d32
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandler.java
@@ -0,0 +1,58 @@
+/*
+ * 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.protocol.protobuf.operations;
+
+import org.apache.geode.protocol.protobuf.ProtobufUtilities;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.Region;
+import org.apache.geode.protocol.operations.OperationHandler;
+import org.apache.geode.protocol.protobuf.BasicTypes;
+import org.apache.geode.protocol.protobuf.ClientProtocol;
+import org.apache.geode.protocol.protobuf.RegionAPI;
+import org.apache.geode.serialization.SerializationService;
+import org.apache.geode.protocol.protobuf.EncodingTypeTranslator;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+
+public class GetRequestOperationHandler
+    implements OperationHandler<RegionAPI.GetRequest, RegionAPI.GetResponse> {
+
+  @Override
+  public RegionAPI.GetResponse process(SerializationService serializationService,
+      RegionAPI.GetRequest request, Cache cache)
+      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
+    String regionName = request.getRegionName();
+    BasicTypes.EncodedValue key = request.getKey();
+    BasicTypes.EncodingType encodingType = key.getEncodingType();
+    byte[] value = key.getValue().toByteArray();
+    Object decodedValue = serializationService.decode(encodingType, value);
+
+    Region region = cache.getRegion(regionName);
+    Object resultValue = region.get(decodedValue);
+
+    BasicTypes.EncodingType resultEncodingType =
+        EncodingTypeTranslator.getEncodingTypeForObject(resultValue);
+    byte[] resultEncodedValue = serializationService.encode(resultEncodingType, resultValue);
+
+    return RegionAPI.GetResponse.newBuilder()
+        .setResult(ProtobufUtilities.getEncodedValue(resultEncodingType, resultEncodedValue))
+        .build();
+  }
+
+  @Override
+  public int getOperationCode() {
+    return ClientProtocol.Request.RequestAPICase.GETREQUEST.getNumber();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/serializer/ProtobufProtocolSerializer.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/serializer/ProtobufProtocolSerializer.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/serializer/ProtobufProtocolSerializer.java
new file mode 100644
index 0000000..683e42f
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/serializer/ProtobufProtocolSerializer.java
@@ -0,0 +1,41 @@
+/*
+ * 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.protocol.protobuf.serializer;
+
+import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
+import org.apache.geode.protocol.serializer.ProtocolSerializer;
+import org.apache.geode.protocol.protobuf.ClientProtocol;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class ProtobufProtocolSerializer implements ProtocolSerializer<ClientProtocol.Message> {
+  @Override
+  public ClientProtocol.Message deserialize(InputStream inputStream)
+      throws InvalidProtocolMessageException {
+    try {
+      return ClientProtocol.Message.parseDelimitedFrom(inputStream);
+    } catch (IOException e) {
+      throw new InvalidProtocolMessageException("Failed to parse Protobuf Message", e);
+    }
+  }
+
+  @Override
+  public void serialize(ClientProtocol.Message inputMessage, OutputStream outputStream)
+      throws IOException {
+    inputMessage.writeDelimitedTo(outputStream);
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/protocol/serializer/ProtocolSerializer.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/serializer/ProtocolSerializer.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/serializer/ProtocolSerializer.java
new file mode 100644
index 0000000..7191d87
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/serializer/ProtocolSerializer.java
@@ -0,0 +1,31 @@
+/*
+ * 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.protocol.serializer;
+
+import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * This interface is used to translate between binary data and protocol specific messages.
+ * @param <T> The message type of the protocol.
+ */
+public interface ProtocolSerializer<T> {
+  T deserialize(InputStream inputStream) throws InvalidProtocolMessageException;
+
+  void serialize(T inputMessage, OutputStream outputStream) throws IOException;
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/serialization/ProtobufSerializationService.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/ProtobufSerializationService.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/ProtobufSerializationService.java
deleted file mode 100644
index 9d78245..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/ProtobufSerializationService.java
+++ /dev/null
@@ -1,50 +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.serialization;
-
-import org.apache.geode.protocol.protobuf.BasicTypes;
-import org.apache.geode.serialization.protobuf.translation.EncodingTypeTranslator;
-import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
-import org.apache.geode.serialization.registry.SerializationCodecRegistry;
-import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
-import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
-
-public class ProtobufSerializationService implements SerializationService<BasicTypes.EncodingType> {
-  private SerializationCodecRegistry serializationCodecRegistry = new SerializationCodecRegistry();
-
-  public ProtobufSerializationService() throws CodecAlreadyRegisteredForTypeException {}
-
-  @Override
-  public byte[] encode(BasicTypes.EncodingType encodingTypeValue, Object value)
-      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
-    TypeCodec codecForType = getTypeCodecForProtobufType(encodingTypeValue);
-    return codecForType.encode(value);
-  }
-
-  @Override
-  public Object decode(BasicTypes.EncodingType encodingTypeValue, byte[] value)
-      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
-    TypeCodec codecForType = getTypeCodecForProtobufType(encodingTypeValue);
-    return codecForType.decode(value);
-  }
-
-  private TypeCodec getTypeCodecForProtobufType(BasicTypes.EncodingType encodingTypeValue)
-      throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException {
-    SerializationType serializationTypeForEncodingType =
-        EncodingTypeTranslator.getSerializationTypeForEncodingType(encodingTypeValue);
-
-    return serializationCodecRegistry.getCodecForType(serializationTypeForEncodingType);
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/serialization/exception/UnsupportedEncodingTypeException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/exception/UnsupportedEncodingTypeException.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/exception/UnsupportedEncodingTypeException.java
index 9d75f56..6d2a032 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/exception/UnsupportedEncodingTypeException.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/exception/UnsupportedEncodingTypeException.java
@@ -14,6 +14,9 @@
  */
 package org.apache.geode.serialization.exception;
 
+/**
+ * This indicates an encoding type that we don't know how to handle.
+ */
 public class UnsupportedEncodingTypeException extends Exception {
   public UnsupportedEncodingTypeException(String message) {
     super(message);

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeTranslator.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeTranslator.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeTranslator.java
deleted file mode 100644
index 667996d..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeTranslator.java
+++ /dev/null
@@ -1,83 +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.serialization.protobuf.translation;
-
-import org.apache.geode.pdx.JSONFormatter;
-import org.apache.geode.pdx.PdxInstance;
-import org.apache.geode.protocol.protobuf.BasicTypes;
-import org.apache.geode.serialization.SerializationType;
-import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
-
-public abstract class EncodingTypeTranslator {
-  public static SerializationType getSerializationTypeForEncodingType(
-      BasicTypes.EncodingType encodingType) throws UnsupportedEncodingTypeException {
-    switch (encodingType) {
-      case INT:
-        return SerializationType.INT;
-      case BYTE:
-        return SerializationType.BYTE;
-      case JSON:
-        return SerializationType.JSON;
-      case LONG:
-        return SerializationType.LONG;
-      case FLOAT:
-        return SerializationType.FLOAT;
-      case SHORT:
-        return SerializationType.SHORT;
-      case BINARY:
-        return SerializationType.BINARY;
-      case DOUBLE:
-        return SerializationType.DOUBLE;
-      case STRING:
-        return SerializationType.STRING;
-      case BOOLEAN:
-        return SerializationType.BOOLEAN;
-      default:
-        throw new UnsupportedEncodingTypeException(
-            "No serialization type found for protobuf encoding type: " + encodingType);
-    }
-  }
-
-  public static BasicTypes.EncodingType getEncodingTypeForObject(Object resultValue)
-      throws UnsupportedEncodingTypeException {
-    if (resultValue instanceof Integer) {
-      return BasicTypes.EncodingType.INT;
-    } else if (resultValue instanceof Byte) {
-      return BasicTypes.EncodingType.BYTE;
-    } else if (resultValue instanceof PdxInstance) {
-      String pdxClassName = ((PdxInstance) resultValue).getClassName();
-      if (pdxClassName.equals(JSONFormatter.JSON_CLASSNAME)) {
-        return BasicTypes.EncodingType.JSON;
-      }
-    } else if (resultValue instanceof Long) {
-      return BasicTypes.EncodingType.LONG;
-    } else if (resultValue instanceof Float) {
-      return BasicTypes.EncodingType.FLOAT;
-    } else if (resultValue instanceof Short) {
-      return BasicTypes.EncodingType.SHORT;
-    } else if (resultValue instanceof byte[]) {
-      return BasicTypes.EncodingType.BINARY;
-    } else if (resultValue instanceof Double) {
-      return BasicTypes.EncodingType.DOUBLE;
-    } else if (resultValue instanceof String) {
-      return BasicTypes.EncodingType.STRING;
-    } else if (resultValue instanceof Boolean) {
-      return BasicTypes.EncodingType.BOOLEAN;
-    }
-
-    throw new UnsupportedEncodingTypeException(
-        "We cannot translate: " + resultValue.getClass() + " into a specific Protobuf Encoding");
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/exception/UnsupportedEncodingTypeException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/exception/UnsupportedEncodingTypeException.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/exception/UnsupportedEncodingTypeException.java
deleted file mode 100644
index ad01eac..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/exception/UnsupportedEncodingTypeException.java
+++ /dev/null
@@ -1,21 +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.serialization.protobuf.translation.exception;
-
-public class UnsupportedEncodingTypeException extends Exception {
-  public UnsupportedEncodingTypeException(String message) {
-    super(message);
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecAlreadyRegisteredForTypeException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecAlreadyRegisteredForTypeException.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecAlreadyRegisteredForTypeException.java
index 678d374..7e73ba9 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecAlreadyRegisteredForTypeException.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecAlreadyRegisteredForTypeException.java
@@ -14,6 +14,9 @@
  */
 package org.apache.geode.serialization.registry.exception;
 
+/**
+ * This indicates that we're attempting to register a codec for a type which we already have a handler for.
+ */
 public class CodecAlreadyRegisteredForTypeException extends Exception {
   public CodecAlreadyRegisteredForTypeException(String message) {
     super(message);

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecNotRegisteredForTypeException.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecNotRegisteredForTypeException.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecNotRegisteredForTypeException.java
index a1a6408..58cb691 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecNotRegisteredForTypeException.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/registry/exception/CodecNotRegisteredForTypeException.java
@@ -14,6 +14,9 @@
  */
 package org.apache.geode.serialization.registry.exception;
 
+/**
+ * This indicates we're attempting to handle a type for which we don't have a registered codec.
+ */
 public class CodecNotRegisteredForTypeException extends Exception {
   public CodecNotRegisteredForTypeException(String message) {
     super(message);

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.handler.ProtocolHandler
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.handler.ProtocolHandler b/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.handler.ProtocolHandler
deleted file mode 100644
index 9af7c5d..0000000
--- a/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.handler.ProtocolHandler
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.geode.protocol.handler.protobuf.ProtobufProtocolHandler
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.operations.OperationHandler
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.operations.OperationHandler b/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.operations.OperationHandler
index fa7c3c6..b6ec564 100644
--- a/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.operations.OperationHandler
+++ b/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.operations.OperationHandler
@@ -1 +1 @@
-org.apache.geode.protocol.operations.protobuf.GetRequestOperationHandler
\ No newline at end of file
+org.apache.geode.protocol.protobuf.operations.GetRequestOperationHandler
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.serializer.ProtocolSerializer
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.serializer.ProtocolSerializer b/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.serializer.ProtocolSerializer
new file mode 100644
index 0000000..2a9af4e
--- /dev/null
+++ b/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.serializer.ProtocolSerializer
@@ -0,0 +1 @@
+org.apache.geode.protocol.protobuf.serializer.ProtobufProtocolSerializer
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java
index e86e908..e32c711 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java
@@ -18,15 +18,12 @@ import com.google.protobuf.ByteString;
 
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.Region;
-import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
-import org.apache.geode.protocol.handler.ProtobufStreamProcessor;
-import org.apache.geode.protocol.operations.registry.exception.OperationHandlerAlreadyRegisteredException;
-import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException;
+import org.apache.geode.protocol.protobuf.ProtobufStreamProcessor;
 import org.apache.geode.protocol.protobuf.BasicTypes;
 import org.apache.geode.protocol.protobuf.ClientProtocol;
 import org.apache.geode.protocol.protobuf.RegionAPI;
 import org.apache.geode.serialization.codec.StringCodec;
-import org.apache.geode.serialization.protobuf.translation.EncodingTypeTranslator;
+import org.apache.geode.protocol.protobuf.EncodingTypeTranslator;
 import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
 import org.apache.geode.serialization.registry.SerializationCodecRegistry;
 import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
@@ -37,7 +34,10 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import java.io.ByteArrayInputStream;
@@ -52,6 +52,7 @@ public class IntegrationTest {
   public static final String TEST_REGION = "test region";
   private StringCodec stringCodec;
   private Cache cacheStub;
+  private Region regionStub;
 
   @Before
   public void setup() throws CodecAlreadyRegisteredForTypeException,
@@ -59,15 +60,13 @@ public class IntegrationTest {
     SerializationCodecRegistry serializationCodecRegistry = new SerializationCodecRegistry();
     stringCodec = (StringCodec) serializationCodecRegistry.getCodecForType(
         EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.STRING));
-    cacheStub = getCacheStub();
+    regionStub = getRegionStub();
+    cacheStub = getCacheStub(regionStub);
   }
 
   @Test
-  public void testFullRequestToCache()
-      throws OperationHandlerAlreadyRegisteredException, CodecAlreadyRegisteredForTypeException,
-      UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException,
-      OperationHandlerNotRegisteredException, IOException, InvalidProtocolMessageException {
-
+  public void testGetRequestProcessed()
+      throws Exception {
     ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
 
     ProtobufStreamProcessor streamProcessor = new ProtobufStreamProcessor();
@@ -80,14 +79,19 @@ public class IntegrationTest {
     Assert.assertEquals(BasicTypes.EncodingType.STRING, getResponse.getResult().getEncodingType());
     String actualValue = stringCodec.decode(getResponse.getResult().getValue().toByteArray());
     Assert.assertEquals(TEST_VALUE, actualValue);
+    verify(regionStub, times(1)).get(TEST_KEY);
+    verify(regionStub, times(1)).get(anyString());
   }
 
-  private Cache getCacheStub() {
-    Region regionStub = mock(Region.class);
+  private Region getRegionStub() {
+    regionStub = mock(Region.class);
     when(regionStub.get(TEST_KEY)).thenReturn(TEST_VALUE);
+    return regionStub;
+  }
 
+  private Cache getCacheStub(Region region) {
     Cache cacheStub = mock(Cache.class);
-    when(cacheStub.getRegion(TEST_REGION)).thenReturn(regionStub);
+    when(cacheStub.getRegion(TEST_REGION)).thenReturn(region);
     return cacheStub;
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsProcessorTest.java b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsProcessorTest.java
deleted file mode 100644
index 1ec7a02..0000000
--- a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsProcessorTest.java
+++ /dev/null
@@ -1,64 +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.client.protocol;
-
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.RegionService;
-import org.apache.geode.protocol.OpsProcessor;
-import org.apache.geode.protocol.operations.OperationHandler;
-import org.apache.geode.protocol.operations.ProtobufRequestOperationParser;
-import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry;
-import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException;
-import org.apache.geode.protocol.protobuf.ClientProtocol;
-import org.apache.geode.protocol.protobuf.RegionAPI;
-import org.apache.geode.serialization.SerializationService;
-import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
-import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
-import org.apache.geode.test.junit.categories.UnitTest;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-@Category(UnitTest.class)
-public class OpsProcessorTest {
-  @Test
-  public void testOpsProcessor() throws CodecNotRegisteredForTypeException,
-      OperationHandlerNotRegisteredException, UnsupportedEncodingTypeException {
-    OperationsHandlerRegistry opsHandlerRegistryStub = mock(OperationsHandlerRegistry.class);
-    OperationHandler operationHandlerStub = mock(OperationHandler.class);
-    SerializationService serializationServiceStub = mock(SerializationService.class);
-    Cache dummyCache = mock(Cache.class);
-    int operationID = ClientProtocol.Request.RequestAPICase.GETREQUEST.getNumber();
-
-    ClientProtocol.Request messageRequest = ClientProtocol.Request.newBuilder()
-        .setGetRequest(RegionAPI.GetRequest.newBuilder()).build();
-
-    RegionAPI.GetResponse expectedResponse = RegionAPI.GetResponse.newBuilder().build();
-
-    when(opsHandlerRegistryStub.getOperationHandlerForOperationId(operationID))
-        .thenReturn(operationHandlerStub);
-    when(operationHandlerStub.process(serializationServiceStub,
-        ProtobufRequestOperationParser.getRequestForOperationTypeID(messageRequest), dummyCache))
-            .thenReturn(expectedResponse);
-
-    OpsProcessor processor = new OpsProcessor(opsHandlerRegistryStub, serializationServiceStub);
-    ClientProtocol.Response response = processor.process(messageRequest, dummyCache);
-    Assert.assertEquals(expectedResponse, response.getGetResponse());
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/test/java/org/apache/geode/protocol/handler/ProtobufProtocolHandlerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/handler/ProtobufProtocolHandlerJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/handler/ProtobufProtocolHandlerJUnitTest.java
deleted file mode 100644
index 21c3107..0000000
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/handler/ProtobufProtocolHandlerJUnitTest.java
+++ /dev/null
@@ -1,88 +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.protocol.handler;
-
-import org.apache.geode.client.protocol.MessageUtil;
-import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
-import org.apache.geode.protocol.handler.ProtocolHandler;
-import org.apache.geode.protocol.handler.protobuf.ProtobufProtocolHandler;
-import org.apache.geode.protocol.protobuf.ClientProtocol;
-import org.apache.geode.test.junit.categories.UnitTest;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ServiceLoader;
-
-@Category(UnitTest.class)
-public class ProtobufProtocolHandlerJUnitTest {
-  private ProtocolHandler<ClientProtocol.Message> protocolHandler;
-
-  @Before
-  public void startup() {
-    ServiceLoader<ProtocolHandler> serviceLoader = ServiceLoader.load(ProtocolHandler.class);
-    for (ProtocolHandler protocolHandler : serviceLoader) {
-      if (protocolHandler instanceof ProtobufProtocolHandler) {
-        this.protocolHandler = protocolHandler;
-      }
-    }
-  }
-
-  @Test
-  public void testDeserializeByteArrayToMessage()
-      throws IOException, InvalidProtocolMessageException {
-    ClientProtocol.Message expectedRequestMessage = MessageUtil.createGetRequestMessage();
-
-    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-
-    expectedRequestMessage.writeDelimitedTo(byteArrayOutputStream);
-    InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
-
-    ClientProtocol.Message actualMessage = protocolHandler.deserialize(inputStream);
-    Assert.assertEquals(expectedRequestMessage, actualMessage);
-  }
-
-  @Test
-  public void testDeserializeInvalidByteThrowsException() throws IOException {
-    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-    byteArrayOutputStream.write("Some incorrect byte array".getBytes());
-    InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
-
-    boolean caughtException = false;
-    try {
-      protocolHandler.deserialize(inputStream);
-    } catch (InvalidProtocolMessageException e) {
-      caughtException = true;
-    }
-    Assert.assertTrue(caughtException);
-  }
-
-  @Test
-  public void testSerializeMessageToByteArray() throws IOException {
-    ClientProtocol.Message message = MessageUtil.createGetRequestMessage();
-    ByteArrayOutputStream expectedByteArrayOutputStream = new ByteArrayOutputStream();
-    message.writeDelimitedTo(expectedByteArrayOutputStream);
-    byte[] expectedByteArray = expectedByteArrayOutputStream.toByteArray();
-
-    ByteArrayOutputStream actualByteArrayOutputStream = new ByteArrayOutputStream();
-    protocolHandler.serialize(message, actualByteArrayOutputStream);
-    Assert.assertArrayEquals(expectedByteArray, actualByteArrayOutputStream.toByteArray());
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandlerTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandlerTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandlerTest.java
index 359db7d..cb98eb7 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandlerTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandlerTest.java
@@ -18,12 +18,12 @@ import com.google.protobuf.ByteString;
 
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionService;
 import org.apache.geode.protocol.protobuf.BasicTypes;
 import org.apache.geode.protocol.protobuf.RegionAPI;
+import org.apache.geode.protocol.protobuf.operations.GetRequestOperationHandler;
 import org.apache.geode.serialization.SerializationService;
 import org.apache.geode.serialization.codec.StringCodec;
-import org.apache.geode.serialization.protobuf.translation.EncodingTypeTranslator;
+import org.apache.geode.protocol.protobuf.EncodingTypeTranslator;
 import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
 import org.apache.geode.serialization.registry.SerializationCodecRegistry;
 import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;

http://git-wip-us.apache.org/repos/asf/geode/blob/31f4de06/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorTest.java
new file mode 100644
index 0000000..9298026
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.protocol.protobuf;
+
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
+import org.apache.geode.protocol.operations.OperationHandler;
+import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry;
+import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException;
+import org.apache.geode.serialization.SerializationService;
+import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
+import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(UnitTest.class)
+public class ProtobufOpsProcessorTest {
+  @Test
+  public void testOpsProcessor() throws CodecNotRegisteredForTypeException,
+    OperationHandlerNotRegisteredException, UnsupportedEncodingTypeException,
+    InvalidProtocolMessageException {
+    OperationsHandlerRegistry opsHandlerRegistryStub = mock(OperationsHandlerRegistry.class);
+    OperationHandler operationHandlerStub = mock(OperationHandler.class);
+    SerializationService serializationServiceStub = mock(SerializationService.class);
+    Cache dummyCache = mock(Cache.class);
+    int operationID = ClientProtocol.Request.RequestAPICase.GETREQUEST.getNumber();
+
+    ClientProtocol.Request messageRequest = ClientProtocol.Request.newBuilder()
+        .setGetRequest(RegionAPI.GetRequest.newBuilder()).build();
+
+    RegionAPI.GetResponse expectedResponse = RegionAPI.GetResponse.newBuilder().build();
+
+    when(opsHandlerRegistryStub.getOperationHandlerForOperationId(operationID))
+        .thenReturn(operationHandlerStub);
+    when(operationHandlerStub.process(serializationServiceStub,
+        ProtobufOpsProcessor.getRequestForOperationTypeID(messageRequest), dummyCache))
+            .thenReturn(expectedResponse);
+
+    ProtobufOpsProcessor
+      processor = new ProtobufOpsProcessor(opsHandlerRegistryStub, serializationServiceStub);
+    ClientProtocol.Response response = processor.process(messageRequest, dummyCache);
+    Assert.assertEquals(expectedResponse, response.getGetResponse());
+  }
+}


[02/46] geode git commit: Remove debug println

Posted by zh...@apache.org.
Remove debug println


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

Branch: refs/heads/feature/GEM-1483
Commit: ee88cd282be5fbe43a2d89cc3c1d4f548ba2e183
Parents: 588c3ed
Author: Jens Deppe <jd...@pivotal.io>
Authored: Thu Jun 15 08:01:46 2017 -0700
Committer: Jens Deppe <jd...@pivotal.io>
Committed: Thu Jun 15 08:01:46 2017 -0700

----------------------------------------------------------------------
 gradle/docker.gradle | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/ee88cd28/gradle/docker.gradle
----------------------------------------------------------------------
diff --git a/gradle/docker.gradle b/gradle/docker.gradle
index 7a74c5d..5c2ef77 100644
--- a/gradle/docker.gradle
+++ b/gradle/docker.gradle
@@ -65,7 +65,7 @@ def dockerConfig = {
 
       args[3] = args[3] + matcher[0][1]
       def workdir = new File(args[3])
-      println "dockerize: making ${workdir}"
+      // println "dockerize: making ${workdir}"
       workdir.mkdirs()
       // println args