geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hiteshkhame...@apache.org
Subject [09/13] geode git commit: GEODE-2995: Handle stream of ProtoBuf encoded messages
Date Mon, 26 Jun 2017 16:26:56 GMT
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 <amurmann@pivotal.io>
Signed-off-by: Brian Rowe <browe@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/develop
Commit: cdcc4d95634ae6377c0198cadba92f52cd436be0
Parents: 4ace36a
Author: Udo Kohlmeyer <ukohlmeyer@pivotal.io>
Authored: Mon Jun 12 15:12:18 2017 -0700
Committer: Hitesh Khamesra <hkhamesra@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


Mime
View raw message