This is an automated email from the ASF dual-hosted git repository.
upthewaterspout pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new be8140d GEODE-4736: Updating statistics in ProtobufOpsProcessor
be8140d is described below
commit be8140dadb386adfb5b18503ef0878d7f7376f56
Author: Dan Smith <[email protected]>
AuthorDate: Thu Feb 22 17:36:04 2018 -0800
GEODE-4736: Updating statistics in ProtobufOpsProcessor
Updating statistics in one place, rather than in each operation.
---
.../protocol/protobuf/v1/ProtobufOpsProcessor.java | 4 +++
.../operations/GetAllRequestOperationHandler.java | 2 --
.../v1/operations/GetRequestOperationHandler.java | 2 --
.../operations/PutAllRequestOperationHandler.java | 2 --
.../v1/operations/PutRequestOperationHandler.java | 31 +++++++++-------------
.../operations/RemoveRequestOperationHandler.java | 19 +++++--------
6 files changed, 24 insertions(+), 36 deletions(-)
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufOpsProcessor.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufOpsProcessor.java
index eca629d..16b1e98 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufOpsProcessor.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufOpsProcessor.java
@@ -75,6 +75,8 @@ public class ProtobufOpsProcessor {
private Result processOperation(ClientProtocol.Message request,
MessageExecutionContext context,
ClientProtocol.Message.MessageTypeCase requestType,
ProtobufOperationContext operationContext)
throws ConnectionStateException, EncodingException, DecodingException {
+
+ long startTime = context.getStatistics().startOperation();
try {
return
operationContext.getOperationHandler().process(serializationService,
operationContext.getFromRequest().apply(request), context);
@@ -83,6 +85,8 @@ public class ProtobufOpsProcessor {
logger.error(exception);
return Failure.of(BasicTypes.ErrorCode.INVALID_REQUEST,
"Invalid execution context found for operation.");
+ } finally {
+ context.getStatistics().endOperation(startTime);
}
}
}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetAllRequestOperationHandler.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetAllRequestOperationHandler.java
index 9bd64ff..a67551c 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetAllRequestOperationHandler.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetAllRequestOperationHandler.java
@@ -52,7 +52,6 @@ public class GetAllRequestOperationHandler
"Region \"" + regionName + "\" not found");
}
- long startTime = messageExecutionContext.getStatistics().startOperation();
RegionAPI.GetAllResponse.Builder responseBuilder =
RegionAPI.GetAllResponse.newBuilder();
try {
messageExecutionContext.getCache().setReadSerializedForCurrentThread(true);
@@ -60,7 +59,6 @@ public class GetAllRequestOperationHandler
.forEach((key) -> processSingleKey(responseBuilder,
serializationService, region, key));
} finally {
messageExecutionContext.getCache().setReadSerializedForCurrentThread(false);
- messageExecutionContext.getStatistics().endOperation(startTime);
}
return Success.of(responseBuilder.build());
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetRequestOperationHandler.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetRequestOperationHandler.java
index 4b03922..e7a27ea 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetRequestOperationHandler.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetRequestOperationHandler.java
@@ -47,7 +47,6 @@ public class GetRequestOperationHandler
return Failure.of(BasicTypes.ErrorCode.SERVER_ERROR,
"Region \"" + regionName + "\" not found");
}
- long startOperationTime =
messageExecutionContext.getStatistics().startOperation();
try {
messageExecutionContext.getCache().setReadSerializedForCurrentThread(true);
@@ -66,7 +65,6 @@ public class GetRequestOperationHandler
return
Success.of(RegionAPI.GetResponse.newBuilder().setResult(encodedValue).build());
} finally {
messageExecutionContext.getCache().setReadSerializedForCurrentThread(false);
- messageExecutionContext.getStatistics().endOperation(startOperationTime);
}
}
}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/PutAllRequestOperationHandler.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/PutAllRequestOperationHandler.java
index 8a6027d..3f43e0c 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/PutAllRequestOperationHandler.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/PutAllRequestOperationHandler.java
@@ -52,7 +52,6 @@ public class PutAllRequestOperationHandler
"Region \"" + regionName + "\" not found");
}
- long startTime = messageExecutionContext.getStatistics().startOperation();
RegionAPI.PutAllResponse.Builder builder =
RegionAPI.PutAllResponse.newBuilder();
try {
messageExecutionContext.getCache().setReadSerializedForCurrentThread(true);
@@ -61,7 +60,6 @@ public class PutAllRequestOperationHandler
.forEach((entry) -> processSinglePut(builder, serializationService,
region, entry));
} finally {
- messageExecutionContext.getStatistics().endOperation(startTime);
messageExecutionContext.getCache().setReadSerializedForCurrentThread(false);
}
return Success.of(builder.build());
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/PutRequestOperationHandler.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/PutRequestOperationHandler.java
index b56e3cc..1ea8bb3 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/PutRequestOperationHandler.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/PutRequestOperationHandler.java
@@ -47,26 +47,21 @@ public class PutRequestOperationHandler
"Region \"" + regionName + "\" not found");
}
- long startTime = messageExecutionContext.getStatistics().startOperation();
- try {
- BasicTypes.Entry entry = request.getEntry();
+ BasicTypes.Entry entry = request.getEntry();
- Object decodedValue = serializationService.decode(entry.getValue());
- Object decodedKey = serializationService.decode(entry.getKey());
- if (decodedKey == null || decodedValue == null) {
- return Failure.of(BasicTypes.ErrorCode.INVALID_REQUEST,
- "Key and value must both be non-NULL");
- }
+ Object decodedValue = serializationService.decode(entry.getValue());
+ Object decodedKey = serializationService.decode(entry.getKey());
+ if (decodedKey == null || decodedValue == null) {
+ return Failure.of(BasicTypes.ErrorCode.INVALID_REQUEST,
+ "Key and value must both be non-NULL");
+ }
- try {
- region.put(decodedKey, decodedValue);
- return Success.of(RegionAPI.PutResponse.newBuilder().build());
- } catch (ClassCastException ex) {
- logger.error("Received Put request with invalid key type: {}", ex);
- return Failure.of(BasicTypes.ErrorCode.SERVER_ERROR, ex.toString());
- }
- } finally {
- messageExecutionContext.getStatistics().endOperation(startTime);
+ try {
+ region.put(decodedKey, decodedValue);
+ return Success.of(RegionAPI.PutResponse.newBuilder().build());
+ } catch (ClassCastException ex) {
+ logger.error("Received Put request with invalid key type: {}", ex);
+ return Failure.of(BasicTypes.ErrorCode.SERVER_ERROR, ex.toString());
}
}
}
diff --git
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/RemoveRequestOperationHandler.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/RemoveRequestOperationHandler.java
index a852a76..18eeca9 100644
---
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/RemoveRequestOperationHandler.java
+++
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/RemoveRequestOperationHandler.java
@@ -48,18 +48,13 @@ public class RemoveRequestOperationHandler
"Region \"" + regionName + "\" not found");
}
- long startTime = messageExecutionContext.getStatistics().startOperation();
- try {
- Object decodedKey = serializationService.decode(request.getKey());
- if (decodedKey == null) {
- return Failure.of(BasicTypes.ErrorCode.INVALID_REQUEST,
- "NULL is not a valid key for removal.");
- }
- region.remove(decodedKey);
-
- return Success.of(RegionAPI.RemoveResponse.newBuilder().build());
- } finally {
- messageExecutionContext.getStatistics().endOperation(startTime);
+ Object decodedKey = serializationService.decode(request.getKey());
+ if (decodedKey == null) {
+ return Failure.of(BasicTypes.ErrorCode.INVALID_REQUEST,
+ "NULL is not a valid key for removal.");
}
+ region.remove(decodedKey);
+
+ return Success.of(RegionAPI.RemoveResponse.newBuilder().build());
}
}
--
To stop receiving notification emails like this one, please contact
[email protected].