dcapwell commented on a change in pull request #1180:
URL: https://github.com/apache/cassandra/pull/1180#discussion_r702152268
##########
File path: src/java/org/apache/cassandra/service/reads/ReadCallback.java
##########
@@ -215,13 +300,33 @@ public void onResponse(Message<ReadResponse> message)
Map<ParamType, Object> params = message.header.params();
if (params.containsKey(ParamType.TOMBSTONE_ABORT))
{
- getWarningCounter().addTombstoneAbort(message.from(), (Integer)
params.get(ParamType.TOMBSTONE_ABORT));
+ getWarningCounter().tombstones.addAbort(message.from(), (Integer)
params.get(ParamType.TOMBSTONE_ABORT));
onFailure(message.from(),
RequestFailureReason.READ_TOO_MANY_TOMBSTONES);
return;
}
else if (params.containsKey(ParamType.TOMBSTONE_WARNING))
{
- getWarningCounter().addTombstoneWarning(message.from(), (Integer)
params.get(ParamType.TOMBSTONE_WARNING));
+ getWarningCounter().tombstones.addWarning(message.from(),
(Integer) params.get(ParamType.TOMBSTONE_WARNING));
+ }
+ if (params.containsKey(ParamType.LOCAL_READ_TOO_LARGE_ABORT))
+ {
+ getWarningCounter().localReadSizeTooLarge.addAbort(message.from(),
(Long) params.get(ParamType.LOCAL_READ_TOO_LARGE_ABORT));
+ onFailure(message.from(), RequestFailureReason.READ_TOO_LARGE);
+ return;
+ }
+ else if (params.containsKey(ParamType.LOCAL_READ_TOO_LARGE_WARNING))
+ {
+
getWarningCounter().localReadSizeTooLarge.addWarning(message.from(), (Long)
params.get(ParamType.LOCAL_READ_TOO_LARGE_WARNING));
+ }
+ if (params.containsKey(ParamType.ROW_INDEX_ENTRY_TOO_LARGE_ABORT))
+ {
+ getWarningCounter().rowIndexTooLarge.addAbort(message.from(),
(Long) params.get(ParamType.ROW_INDEX_ENTRY_TOO_LARGE_ABORT));
+ onFailure(message.from(), RequestFailureReason.READ_TOO_LARGE);
+ return;
+ }
+ else if
(params.containsKey(ParamType.ROW_INDEX_ENTRY_TOO_LARGE_WARNING))
+ {
+ getWarningCounter().rowIndexTooLarge.addWarning(message.from(),
(Long) params.get(ParamType.ROW_INDEX_ENTRY_TOO_LARGE_WARNING));
Review comment:
can you explain more? Each block has basically the same shape, but not
clear how to refactor to clean up (which field to we access? what is the
`RequestFailureReason`?
This is the best I can see
```
private RequestFailureReason updateCounters(InetAddressAndPort from,
Map<ParamType, Object>
params,
ParamType abort,
ParamType warn,
RequestFailureReason
reason,
Function<WarningContext,
WarnAbortCounter> fieldAccess)
{
if (params.containsKey(abort))
{
fieldAccess.apply(getWarningContext()).addAbort(from,
((Number) params.get(abort)).longValue());
return reason;
}
else if (params.containsKey(warn))
{
fieldAccess.apply(getWarningContext()).addWarning(from,
(Integer) params.get(warn));
}
return null;
}
```
and usage
```
updateCounters(message.from(), params, ParamType.TOMBSTONE_ABORT,
ParamType.TOMBSTONE_WARNING, RequestFailureReason.READ_TOO_MANY_TOMBSTONES, ctx
-> ctx.tombstones);
```
is this what you had in mind?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]