geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject geode git commit: GEODE-2995: Added GetRequestOperationHandler.java and cleaned up some code
Date Thu, 15 Jun 2017 00:08:27 GMT
Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-2995 d790ed5d8 -> b0f48d19f


GEODE-2995: Added GetRequestOperationHandler.java and cleaned up some code


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

Branch: refs/heads/feature/GEODE-2995
Commit: b0f48d19f79dcd666bde11f9d95f59a32ecb6613
Parents: d790ed5
Author: Udo Kohlmeyer <ukohlmeyer@pivotal.io>
Authored: Wed Jun 14 17:07:34 2017 -0700
Committer: Udo Kohlmeyer <ukohlmeyer@pivotal.io>
Committed: Wed Jun 14 17:07:34 2017 -0700

----------------------------------------------------------------------
 .../protocol/operations/OperationHandler.java   |  7 +-
 .../ProtobufRequestOperationParser.java         | 33 ++++++++
 .../protobuf/GetRequestOperationHandler.java    | 76 ++++++++++++++++++
 .../registry/OperationsHandlerRegistry.java     |  8 ++
 .../ProtobufSerializationServiceImpl.java       | 56 +++++++++++++
 .../serialization/SerializationService.java     | 28 +++++++
 .../SerializationServiceException.java          | 23 ++++++
 ...codingTypeToSerializationTypeTranslator.java | 50 ------------
 .../translation/EncodingTypeTranslator.java     | 83 ++++++++++++++++++++
 ...e.geode.protocol.operations.OperationHandler |  1 +
 .../geode/client/protocol/OpsProcessorTest.java | 67 ++++------------
 .../ProtobufRequestOperationParser.java         | 31 --------
 .../OperationsHandlerRegistryJUnitTest.java     |  3 +-
 ...eToSerializationTypeTranslatorJUnitTest.java | 12 +--
 14 files changed, 338 insertions(+), 140 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/b0f48d19/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 c494855..c93a22a 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
@@ -14,6 +14,9 @@
  */
 package org.apache.geode.protocol.operations;
 
-public interface OperationHandler<T> {
-  Object process(Object encodingHandlerRegistry, T request);
+import org.apache.geode.serialization.SerializationService;
+
+public interface OperationHandler<Req, Resp> {
+  Resp process(SerializationService serializationService, Req request);
+  int getOperationCode();
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/b0f48d19/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/b0f48d19/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..ca5698e
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandler.java
@@ -0,0 +1,76 @@
+/*
+ * 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.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.serialization.exception.SerializationServiceException;
+import org.apache.geode.serialization.protobuf.translation.EncodingTypeTranslator;
+import org.apache.geode.serialization.protobuf.translation.exception.UnsupportedEncodingTypeException;
+
+public class GetRequestOperationHandler
+    implements OperationHandler<RegionAPI.GetRequest, RegionAPI.GetResponse> {
+  @Override
+  public RegionAPI.GetResponse process(SerializationService serializationService,
+                                       RegionAPI.GetRequest request) {
+    try {
+      String regionName = request.getRegionName();
+      BasicTypes.EncodedValue key = request.getKey();
+      BasicTypes.EncodingType encodingType = key.getEncodingType();
+      byte[] value = key.getValue().toByteArray();
+
+      Object decodedValue = null;
+      try {
+        decodedValue = serializationService.decode(encodingType, value);
+      } catch (SerializationServiceException e) {
+        e.printStackTrace();
+      }
+
+      Region region = getRegionForName(regionName);
+      Object resultValue = region.get(decodedValue);
+
+      BasicTypes.EncodingType resultEncodingType = null;
+
+      resultEncodingType = EncodingTypeTranslator.getEncodingTypeForObject(resultValue);
+
+      byte[] resultEncodedValue = serializationService.encode(resultEncodingType, resultValue);
+
+//      BasicTypes.EncodedValue
+//          encodedValue =
+//          ProtobufMessageUtil.createEncodedValueFrom(resultEncodingType, resultEncodedValue);
+//    return ProtobufMessageUtil.createGetResponseFrom(encodedValue);
+      return null;
+    } catch (UnsupportedEncodingTypeException e) {
+      e.printStackTrace();
+      throw new RuntimeException("We need to handle exceptions with an error response");
+    }
+  }
+
+  @Override
+  public int getOperationCode() {
+    return ClientProtocol.Request.RequestAPICase.GETREQUEST.getNumber();
+  }
+
+  private Region getRegionForName(String regionName) {
+//    return regionService.getRegion(regionName);
+    return null;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/b0f48d19/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 2e9b40a..9900499 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
@@ -19,10 +19,18 @@ import org.apache.geode.protocol.operations.registry.exception.OperationHandlerA
 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);

http://git-wip-us.apache.org/repos/asf/geode/blob/b0f48d19/geode-protobuf/src/main/java/org/apache/geode/serialization/ProtobufSerializationServiceImpl.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/ProtobufSerializationServiceImpl.java
b/geode-protobuf/src/main/java/org/apache/geode/serialization/ProtobufSerializationServiceImpl.java
new file mode 100644
index 0000000..ee8d965
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/ProtobufSerializationServiceImpl.java
@@ -0,0 +1,56 @@
+/*
+ * 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.SerializationServiceException;
+import org.apache.geode.serialization.protobuf.translation.EncodingTypeTranslator;
+import org.apache.geode.serialization.protobuf.translation.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 ProtobufSerializationServiceImpl implements SerializationService<BasicTypes.EncodingType>
{
+  private SerializationCodecRegistry serializationCodecRegistry = new SerializationCodecRegistry();
+  private EncodingTypeTranslator translator = new EncodingTypeTranslator();
+
+  public ProtobufSerializationServiceImpl() throws CodecAlreadyRegisteredForTypeException
{
+  }
+
+  @Override
+  public Object decode(BasicTypes.EncodingType encodingTypeValue, byte[] value)
+      throws SerializationServiceException {
+    try {
+      SerializationType
+          serializationTypeForEncodingType =
+          translator.getSerializationTypeForEncodingType(encodingTypeValue);
+
+      TypeCodec
+          codecForType =
+          serializationCodecRegistry.getCodecForType(serializationTypeForEncodingType);
+      return codecForType.decode(value);
+    } catch (UnsupportedEncodingTypeException | CodecNotRegisteredForTypeException e) {
+      e.printStackTrace();
+      throw new SerializationServiceException("",e);
+    }
+  }
+
+  @Override
+  public byte[] encode(BasicTypes.EncodingType encodingTypeValue, Object value) {
+    return new byte[0];
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/b0f48d19/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..8ad64da
--- /dev/null
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationService.java
@@ -0,0 +1,28 @@
+/*
+ * 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.SerializationServiceException;
+import org.apache.geode.serialization.protobuf.translation.exception.UnsupportedEncodingTypeException;
+
+public interface SerializationService<T> {
+
+  Object decode(T encodingTypeValue, byte[] value)
+      throws UnsupportedEncodingTypeException, SerializationServiceException;
+  byte[] encode(T encodingTypeValue, Object value);
+}

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

http://git-wip-us.apache.org/repos/asf/geode/blob/b0f48d19/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslator.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslator.java
b/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslator.java
deleted file mode 100644
index 6ad053c..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslator.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.protobuf.translation;
-
-import org.apache.geode.protocol.protobuf.BasicTypes;
-import org.apache.geode.serialization.SerializationType;
-import org.apache.geode.serialization.protobuf.translation.exception.UnsupportedEncodingTypeException;
-
-public class EncodingTypeToSerializationTypeTranslator {
-  public 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);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/b0f48d19/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..7f014b5
--- /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.protobuf.translation.exception.UnsupportedEncodingTypeException;
+
+public class EncodingTypeTranslator {
+  public 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/b0f48d19/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/b0f48d19/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
index 7f3a86c..5cec598 100644
--- 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
@@ -18,18 +18,14 @@ package org.apache.geode.client.protocol;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import com.google.protobuf.ByteString;
-
 import org.apache.geode.protocol.operations.OperationHandler;
 //import org.apache.geode.protocol.operations.ProtobufRequestOperationParser;
+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.BasicTypes;
 import org.apache.geode.protocol.protobuf.ClientProtocol;
 import org.apache.geode.protocol.protobuf.RegionAPI;
-import org.apache.geode.serialization.SerializationType;
-import org.apache.geode.serialization.TypeCodec;
-import org.apache.geode.serialization.registry.SerializationCodecRegistry;
+import org.apache.geode.serialization.SerializationService;
 import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
 import org.junit.Assert;
 import org.junit.Test;
@@ -39,68 +35,40 @@ public class OpsProcessorTest {
   public void testOpsProcessor() throws CodecNotRegisteredForTypeException {
     OperationsHandlerRegistry opsHandlerRegistry = mock(OperationsHandlerRegistry.class);
     OperationHandler operationHandlerStub = mock(OperationHandler.class);
-    SerializationCodecRegistry serializationCodecRegistry = mock(SerializationCodecRegistry.class);
-
-    when(serializationCodecRegistry.getCodecForType(SerializationType.STRING))
-        .thenReturn(new TypeCodec<String>() {
-          @Override
-          public String decode(byte[] incoming) {
-            return new String(incoming);
-          }
-
-          @Override
-          public byte[] encode(String incoming) {
-            return incoming.getBytes();
-          }
+    SerializationService serializationService = mock(SerializationService.class);
 
-          @Override
-          public SerializationType getSerializationType() {
-            return null;
-          }
-        });
+//    when(serializationService.encode(BasicTypes.EncodingType.STRING,"10"))
+//        .thenReturn("10".getBytes(Charset.forName("UTF-8")));
 
     ClientProtocol.Request messageRequest = ClientProtocol.Request.newBuilder()
         .setGetRequest(RegionAPI.GetRequest.newBuilder()).build();
-    RegionAPI.GetResponse expectedResponse = getGetResponse(serializationCodecRegistry);
+    RegionAPI.GetResponse expectedResponse = RegionAPI.GetResponse.newBuilder().build();
     try {
       when(opsHandlerRegistry.getOperationHandlerForOperationId(2))
           .thenReturn(operationHandlerStub);
     } catch (OperationHandlerNotRegisteredException e) {
       e.printStackTrace();
     }
-//    when(operationHandlerStub.process(serializationCodecRegistry,
-//        ProtobufRequestOperationParser.getRequestForOperationTypeID(messageRequest)))
-//            .thenReturn(expectedResponse);
+    when(operationHandlerStub.process(serializationService,
+        ProtobufRequestOperationParser.getRequestForOperationTypeID(messageRequest)))
+            .thenReturn(expectedResponse);
 
 
 
-    OpsProcessor processor = new OpsProcessor(opsHandlerRegistry, serializationCodecRegistry);
+    OpsProcessor processor = new OpsProcessor(opsHandlerRegistry, serializationService);
     ClientProtocol.Response response = processor.process(messageRequest);
     Assert.assertEquals(expectedResponse, response.getGetResponse());
 
   }
 
-  private RegionAPI.GetResponse getGetResponse(SerializationCodecRegistry serializationCodecRegistry)
-      throws CodecNotRegisteredForTypeException {
-    RegionAPI.GetResponse.Builder getResponseBuilder = RegionAPI.GetResponse.newBuilder();
-    BasicTypes.EncodedValue.Builder encodedValueBuilder = BasicTypes.EncodedValue.newBuilder();
-    TypeCodec typeCodec =
-        serializationCodecRegistry.getCodecForType(SerializationType.STRING);
-    byte[] serializedValue = typeCodec.encode("10");
-    encodedValueBuilder.setValue(ByteString.copyFrom(serializedValue));
-    encodedValueBuilder.setEncodingType(BasicTypes.EncodingType.STRING);
-    getResponseBuilder.setResult(encodedValueBuilder);
-    return getResponseBuilder.build();
-  }
-
   private class OpsProcessor {
     private final OperationsHandlerRegistry opsHandlerRegistry;
-    private final SerializationCodecRegistry serializationCodecRegistry;
+    private final SerializationService serializationService;
 
     public OpsProcessor(OperationsHandlerRegistry opsHandlerRegistry,
-                        SerializationCodecRegistry serializationCodecRegistry) {
+                        SerializationService serializationService) {
       this.opsHandlerRegistry = opsHandlerRegistry;
-      this.serializationCodecRegistry = serializationCodecRegistry;
+      this.serializationService = serializationService;
     }
 
     public ClientProtocol.Response process(ClientProtocol.Request request) {
@@ -111,11 +79,10 @@ public class OpsProcessorTest {
         e.printStackTrace();
       }
 
-//      Object responseMessage = opsHandler.process(serializationCodecRegistry,
-//          ProtobufRequestOperationParser.getRequestForOperationTypeID(request));
-//      return ClientProtocol.Response.newBuilder()
-//          .setGetResponse((RegionAPI.GetResponse) responseMessage).build();
-      return null;
+      Object responseMessage = opsHandler.process(serializationService,
+          ProtobufRequestOperationParser.getRequestForOperationTypeID(request));
+      return ClientProtocol.Response.newBuilder()
+          .setGetResponse((RegionAPI.GetResponse) responseMessage).build();
     }
   }
 }

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

http://git-wip-us.apache.org/repos/asf/geode/blob/b0f48d19/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
index 9a81706..9b8209e 100644
--- 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
@@ -7,6 +7,7 @@ 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.serialization.SerializationService;
 import org.apache.geode.test.junit.categories.UnitTest;
 import org.junit.Before;
 import org.junit.Test;
@@ -72,7 +73,7 @@ public class OperationsHandlerRegistryJUnitTest {
   private class DummyOperationHandler implements OperationHandler {
 
     @Override
-    public Object process(Object encodingHandlerRegistry, Object request) {
+    public Object process(SerializationService serializationService, Object request) {
       return null;
     }
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/b0f48d19/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 2d602c9..0cc7dbe 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
@@ -14,8 +14,8 @@ public class EncodingTypeToSerializationTypeTranslatorJUnitTest {
 
   @Test
   public void testTranslateEncodingTypes() throws UnsupportedEncodingTypeException {
-    EncodingTypeToSerializationTypeTranslator translator =
-        new EncodingTypeToSerializationTypeTranslator();
+    EncodingTypeTranslator translator =
+        new EncodingTypeTranslator();
     assertSame(SerializationType.INT,
         translator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.INT));
     assertSame(SerializationType.LONG,
@@ -42,15 +42,15 @@ public class EncodingTypeToSerializationTypeTranslatorJUnitTest {
   public void testTranslateInvalidEncoding_throwsException()
       throws UnsupportedEncodingTypeException {
 
-    EncodingTypeToSerializationTypeTranslator translator =
-        new EncodingTypeToSerializationTypeTranslator();
+    EncodingTypeTranslator translator =
+        new EncodingTypeTranslator();
     translator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.INVALID);
   }
 
   @Test
   public void testAllEncodingTypeTranslations() {
-    EncodingTypeToSerializationTypeTranslator translator =
-        new EncodingTypeToSerializationTypeTranslator();
+    EncodingTypeTranslator translator =
+        new EncodingTypeTranslator();
     for (BasicTypes.EncodingType encodingType : BasicTypes.EncodingType.values()) {
       if (!(encodingType.equals(BasicTypes.EncodingType.UNRECOGNIZED)
           || encodingType.equals(BasicTypes.EncodingType.INVALID))) {


Mime
View raw message