geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bschucha...@apache.org
Subject [geode] branch feature/GEODE-4362 updated: GEODE-3643 Add function execution on specific member
Date Mon, 12 Feb 2018 22:14:30 GMT
This is an automated email from the ASF dual-hosted git repository.

bschuchardt pushed a commit to branch feature/GEODE-4362
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/feature/GEODE-4362 by this push:
     new bf1ed78  GEODE-3643 Add function execution on specific member
bf1ed78 is described below

commit bf1ed786030cef445084cee52fc884f0a499dee3
Author: Bruce Schuchardt <bschuchardt@pivotal.io>
AuthorDate: Mon Feb 12 14:12:26 2018 -0800

    GEODE-3643 Add function execution on specific member
    
    Reworked the abstract superclass of the function execution operation
    handlers and removed the process() methods from its subclasses.
---
 .../AbstractFunctionRequestOperationHandler.java   | 18 ++++++----
 ...cuteFunctionOnGroupRequestOperationHandler.java | 21 +++++-------
 ...uteFunctionOnMemberRequestOperationHandler.java | 38 ++++++++++------------
 ...uteFunctionOnRegionRequestOperationHandler.java | 36 +++++++-------------
 4 files changed, 48 insertions(+), 65 deletions(-)

diff --git a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/AbstractFunctionRequestOperationHandler.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/AbstractFunctionRequestOperationHandler.java
index 3a738c1..ceff45c 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/AbstractFunctionRequestOperationHandler.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/AbstractFunctionRequestOperationHandler.java
@@ -26,6 +26,7 @@ import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.internal.exception.InvalidExecutionContextException;
 import org.apache.geode.internal.i18n.LocalizedStrings;
+import org.apache.geode.internal.protocol.operations.ProtobufOperationHandler;
 import org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
 import org.apache.geode.internal.protocol.protobuf.v1.ClientProtocol;
 import org.apache.geode.internal.protocol.protobuf.v1.Failure;
@@ -36,10 +37,13 @@ import org.apache.geode.internal.protocol.protobuf.v1.serialization.exception.En
 import org.apache.geode.internal.security.SecurityService;
 import org.apache.geode.security.NotAuthorizedException;
 
-public abstract class AbstractFunctionRequestOperationHandler {
+public abstract class AbstractFunctionRequestOperationHandler<Req, Resp>
+    implements ProtobufOperationHandler<Req, Resp> {
 
 
-  public Result process(ProtobufSerializationService serializationService, AbstractMessage
request,
+  @Override
+  public Result<Resp, ClientProtocol.ErrorResponse> process(
+      ProtobufSerializationService serializationService, Req request,
       MessageExecutionContext messageExecutionContext) throws InvalidExecutionContextException
{
 
     final String functionID = getFunctionID(request);
@@ -111,19 +115,19 @@ public abstract class AbstractFunctionRequestOperationHandler {
   }
 
   protected abstract Set<?> parseFilter(ProtobufSerializationService serializationService,
-      AbstractMessage request) throws EncodingException;
+      Req request) throws EncodingException;
 
-  protected abstract String getFunctionID(AbstractMessage request);
+  protected abstract String getFunctionID(Req request);
 
   /** the result of this may be null, which is used by the security service to mean "no region"
*/
-  protected abstract String getRegionName(AbstractMessage request);
+  protected abstract String getRegionName(Req request);
 
   /** region, list of members, etc */
-  protected abstract Object getExecutionTarget(AbstractMessage request, String regionName,
+  protected abstract Object getExecutionTarget(Req request, String regionName,
       MessageExecutionContext executionContext) throws InvalidExecutionContextException;
 
   /** arguments for the function */
-  protected abstract Object getFunctionArguments(AbstractMessage request,
+  protected abstract Object getFunctionArguments(Req request,
       ProtobufSerializationService serializationService) throws EncodingException;
 
   protected abstract Execution getFunctionExecutionObject(Object executionTarget)
diff --git a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ExecuteFunctionOnGroupRequestOperationHandler.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ExecuteFunctionOnGroupRequestOperationHandler.java
index 4d6faa0..65cdce7 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ExecuteFunctionOnGroupRequestOperationHandler.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ExecuteFunctionOnGroupRequestOperationHandler.java
@@ -17,7 +17,6 @@ package org.apache.geode.internal.protocol.protobuf.v1.operations;
 import java.util.List;
 import java.util.Set;
 
-import com.google.protobuf.AbstractMessage;
 import com.google.protobuf.ProtocolStringList;
 
 import org.apache.geode.cache.execute.Execution;
@@ -36,9 +35,8 @@ import org.apache.geode.internal.protocol.protobuf.v1.Result;
 import org.apache.geode.internal.protocol.protobuf.v1.Success;
 import org.apache.geode.internal.protocol.protobuf.v1.serialization.exception.EncodingException;
 
-public class ExecuteFunctionOnGroupRequestOperationHandler
-    extends AbstractFunctionRequestOperationHandler implements
-    ProtobufOperationHandler<ExecuteFunctionOnGroupRequest, ExecuteFunctionOnGroupResponse>
{
+public class ExecuteFunctionOnGroupRequestOperationHandler extends
+    AbstractFunctionRequestOperationHandler<ExecuteFunctionOnGroupRequest, ExecuteFunctionOnGroupResponse>
{
 
 
   @Override
@@ -52,27 +50,26 @@ public class ExecuteFunctionOnGroupRequestOperationHandler
 
   @Override
   protected Set<?> parseFilter(ProtobufSerializationService serializationService,
-      AbstractMessage request) throws EncodingException {
+      ExecuteFunctionOnGroupRequest request) throws EncodingException {
     // filters are not allowed on functions not associated with regions
     return null;
   }
 
   @Override
-  protected String getFunctionID(AbstractMessage request) {
-    return ((ExecuteFunctionOnGroupRequest) request).getFunctionID();
+  protected String getFunctionID(ExecuteFunctionOnGroupRequest request) {
+    return (request).getFunctionID();
   }
 
   @Override
-  protected String getRegionName(AbstractMessage request) {
+  protected String getRegionName(ExecuteFunctionOnGroupRequest request) {
     // region name is not allowed in onMember invocation
     return null;
   }
 
   @Override
-  protected Object getExecutionTarget(AbstractMessage abstractRequest, String regionName,
+  protected Object getExecutionTarget(ExecuteFunctionOnGroupRequest request, String regionName,
       MessageExecutionContext executionContext) throws InvalidExecutionContextException {
 
-    ExecuteFunctionOnGroupRequest request = ((ExecuteFunctionOnGroupRequest) abstractRequest);
     ProtocolStringList groupList = request.getGroupNameList();
 
     // unfortunately FunctionServiceManager throws a FunctionException if there are no
@@ -100,9 +97,9 @@ public class ExecuteFunctionOnGroupRequestOperationHandler
   }
 
   @Override
-  protected Object getFunctionArguments(AbstractMessage request,
+  protected Object getFunctionArguments(ExecuteFunctionOnGroupRequest request,
       ProtobufSerializationService serializationService) throws EncodingException {
-    return serializationService.decode(((ExecuteFunctionOnGroupRequest) request).getArguments());
+    return serializationService.decode((request).getArguments());
   }
 
   @Override
diff --git a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ExecuteFunctionOnMemberRequestOperationHandler.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ExecuteFunctionOnMemberRequestOperationHandler.java
index cc608c4..6ac8fcb 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ExecuteFunctionOnMemberRequestOperationHandler.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ExecuteFunctionOnMemberRequestOperationHandler.java
@@ -18,7 +18,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import com.google.protobuf.AbstractMessage;
 import com.google.protobuf.ProtocolStringList;
 
 import org.apache.geode.cache.execute.Execution;
@@ -26,7 +25,6 @@ import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.distributed.internal.DistributionManager;
 import org.apache.geode.internal.exception.InvalidExecutionContextException;
-import org.apache.geode.internal.protocol.operations.ProtobufOperationHandler;
 import org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
 import org.apache.geode.internal.protocol.protobuf.v1.ClientProtocol;
 import org.apache.geode.internal.protocol.protobuf.v1.Failure;
@@ -38,42 +36,40 @@ import org.apache.geode.internal.protocol.protobuf.v1.Result;
 import org.apache.geode.internal.protocol.protobuf.v1.Success;
 import org.apache.geode.internal.protocol.protobuf.v1.serialization.exception.EncodingException;
 
-public class ExecuteFunctionOnMemberRequestOperationHandler
-    extends AbstractFunctionRequestOperationHandler implements
-    ProtobufOperationHandler<ExecuteFunctionOnMemberRequest, ExecuteFunctionOnMemberResponse>
{
+public class ExecuteFunctionOnMemberRequestOperationHandler extends
+    AbstractFunctionRequestOperationHandler<ExecuteFunctionOnMemberRequest, ExecuteFunctionOnMemberResponse>
{
 
 
-  @Override
-  public Result<ExecuteFunctionOnMemberResponse, ClientProtocol.ErrorResponse> process(
-      ProtobufSerializationService serializationService, ExecuteFunctionOnMemberRequest request,
-      MessageExecutionContext messageExecutionContext) throws InvalidExecutionContextException
{
-
-    return (Result<ExecuteFunctionOnMemberResponse, ClientProtocol.ErrorResponse>)
super.process(
-        serializationService, request, messageExecutionContext);
-  }
+  // @Override
+  // public Result<ExecuteFunctionOnMemberResponse, ClientProtocol.ErrorResponse> process(
+  // ProtobufSerializationService serializationService, ExecuteFunctionOnMemberRequest request,
+  // MessageExecutionContext messageExecutionContext) throws InvalidExecutionContextException
{
+  //
+  // return (Result<ExecuteFunctionOnMemberResponse, ClientProtocol.ErrorResponse>)
super.process(
+  // serializationService, request, messageExecutionContext);
+  // }
 
   @Override
   protected Set<?> parseFilter(ProtobufSerializationService serializationService,
-      AbstractMessage request) throws EncodingException {
+      ExecuteFunctionOnMemberRequest request) throws EncodingException {
     // filters are not allowed on functions not associated with regions
     return null;
   }
 
   @Override
-  protected String getFunctionID(AbstractMessage request) {
-    return ((ExecuteFunctionOnMemberRequest) request).getFunctionID();
+  protected String getFunctionID(ExecuteFunctionOnMemberRequest request) {
+    return (request).getFunctionID();
   }
 
   @Override
-  protected String getRegionName(AbstractMessage request) {
+  protected String getRegionName(ExecuteFunctionOnMemberRequest request) {
     // region name is not allowed in onMember invocation
     return null;
   }
 
   @Override
-  protected Object getExecutionTarget(AbstractMessage abstractRequest, String regionName,
+  protected Object getExecutionTarget(ExecuteFunctionOnMemberRequest request, String regionName,
       MessageExecutionContext executionContext) throws InvalidExecutionContextException {
-    ExecuteFunctionOnMemberRequest request = (ExecuteFunctionOnMemberRequest) abstractRequest;
 
     ProtocolStringList memberNameList = request.getMemberNameList();
 
@@ -102,9 +98,9 @@ public class ExecuteFunctionOnMemberRequestOperationHandler
   }
 
   @Override
-  protected Object getFunctionArguments(AbstractMessage request,
+  protected Object getFunctionArguments(ExecuteFunctionOnMemberRequest request,
       ProtobufSerializationService serializationService) throws EncodingException {
-    return serializationService.decode(((ExecuteFunctionOnMemberRequest) request).getArguments());
+    return serializationService.decode((request).getArguments());
   }
 
   @Override
diff --git a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ExecuteFunctionOnRegionRequestOperationHandler.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ExecuteFunctionOnRegionRequestOperationHandler.java
index b0798ce..2a675db 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ExecuteFunctionOnRegionRequestOperationHandler.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ExecuteFunctionOnRegionRequestOperationHandler.java
@@ -18,13 +18,10 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import com.google.protobuf.AbstractMessage;
-
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.internal.exception.InvalidExecutionContextException;
-import org.apache.geode.internal.protocol.operations.ProtobufOperationHandler;
 import org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
 import org.apache.geode.internal.protocol.protobuf.v1.ClientProtocol;
 import org.apache.geode.internal.protocol.protobuf.v1.Failure;
@@ -36,23 +33,12 @@ import org.apache.geode.internal.protocol.protobuf.v1.Result;
 import org.apache.geode.internal.protocol.protobuf.v1.Success;
 import org.apache.geode.internal.protocol.protobuf.v1.serialization.exception.EncodingException;
 
-public class ExecuteFunctionOnRegionRequestOperationHandler
-    extends AbstractFunctionRequestOperationHandler implements
-    ProtobufOperationHandler<ExecuteFunctionOnRegionRequest, ExecuteFunctionOnRegionResponse>
{
-
-  @Override
-  public Result<ExecuteFunctionOnRegionResponse, ClientProtocol.ErrorResponse> process(
-      ProtobufSerializationService serializationService, ExecuteFunctionOnRegionRequest request,
-      MessageExecutionContext messageExecutionContext) throws InvalidExecutionContextException
{
-
-    return (Result<ExecuteFunctionOnRegionResponse, ClientProtocol.ErrorResponse>)
super.process(
-        serializationService, request, messageExecutionContext);
-  }
+public class ExecuteFunctionOnRegionRequestOperationHandler extends
+    AbstractFunctionRequestOperationHandler<ExecuteFunctionOnRegionRequest, ExecuteFunctionOnRegionResponse>
{
 
   protected Set<Object> parseFilter(ProtobufSerializationService serializationService,
-      AbstractMessage request) throws EncodingException {
-    List<BasicTypes.EncodedValue> encodedFilter =
-        ((ExecuteFunctionOnRegionRequest) request).getKeyFilterList();
+      ExecuteFunctionOnRegionRequest request) throws EncodingException {
+    List<BasicTypes.EncodedValue> encodedFilter = (request).getKeyFilterList();
     Set<Object> filter = new HashSet<>();
 
     for (BasicTypes.EncodedValue filterKey : encodedFilter) {
@@ -62,17 +48,17 @@ public class ExecuteFunctionOnRegionRequestOperationHandler
   }
 
   @Override
-  protected String getFunctionID(AbstractMessage request) {
-    return ((ExecuteFunctionOnRegionRequest) request).getFunctionID();
+  protected String getFunctionID(ExecuteFunctionOnRegionRequest request) {
+    return (request).getFunctionID();
   }
 
   @Override
-  protected String getRegionName(AbstractMessage request) {
-    return ((ExecuteFunctionOnRegionRequest) request).getRegion();
+  protected String getRegionName(ExecuteFunctionOnRegionRequest request) {
+    return (request).getRegion();
   }
 
   @Override
-  protected Object getExecutionTarget(AbstractMessage request, String regionName,
+  protected Object getExecutionTarget(ExecuteFunctionOnRegionRequest request, String regionName,
       MessageExecutionContext executionContext) throws InvalidExecutionContextException {
     final Region<Object, Object> region = executionContext.getCache().getRegion(regionName);
     if (region == null) {
@@ -85,9 +71,9 @@ public class ExecuteFunctionOnRegionRequestOperationHandler
   }
 
   @Override
-  protected Object getFunctionArguments(AbstractMessage request,
+  protected Object getFunctionArguments(ExecuteFunctionOnRegionRequest request,
       ProtobufSerializationService serializationService) throws EncodingException {
-    return serializationService.decode(((ExecuteFunctionOnRegionRequest) request).getArguments());
+    return serializationService.decode((request).getArguments());
   }
 
   @Override

-- 
To stop receiving notification emails like this one, please contact
bschuchardt@apache.org.

Mime
View raw message