szetszwo commented on code in PR #7188:
URL: https://github.com/apache/ozone/pull/7188#discussion_r1757353630
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerDoubleBuffer.java:
##########
@@ -437,17 +453,21 @@ private String addToBatch(Queue<Entry> buffer,
BatchOperation batchOperation) {
*/
private List<Queue<Entry>> splitReadyBufferAtCreateSnapshot() {
final List<Queue<Entry>> response = new ArrayList<>();
-
+ final Set<OzoneManagerProtocolProtos.Type> standaloneBatchCmdTypes =
ImmutableSet.of(
+ OzoneManagerProtocolProtos.Type.SnapshotPurge,
OzoneManagerProtocolProtos.Type.CreateSnapshot);
+ final List<Function<OMResponse, Boolean>> standaloneBatchConditions =
+ ImmutableList.of((omResponse) ->
standaloneBatchCmdTypes.contains(omResponse.getCmdType()));
Review Comment:
BTW, let's add a new `isStandaloneBatchCmdTypes(..)` method. The code
becomes much easier to understand.
```java
private synchronized List<Queue<Entry>> splitReadyBufferAtCreateSnapshot()
{
final List<Queue<Entry>> response = new ArrayList<>();
OMResponse prevResponse = null;
for (final Entry entry : readyBuffer) {
OMResponse omResponse = entry.getResponse().getOMResponse();
// New queue gets created in three conditions:
// 1. It is first element in the response,
// 2. Current request is createSnapshot/purgeSnapshot request.
// 3. Previous request was createSnapshot/purgeSnapshot request.
if (response.isEmpty() || isStandaloneBatchCmdTypes(omResponse) ||
isStandaloneBatchCmdTypes(prevResponse)) {
response.add(new LinkedList<>());
}
response.get(response.size() - 1).add(entry);
prevResponse = omResponse;
}
return response;
}
static boolean isStandaloneBatchCmdTypes(OMResponse response) {
if (response == null) {
return false;
}
final OzoneManagerProtocolProtos.Type type = response.getCmdType();
return type == OzoneManagerProtocolProtos.Type.SnapshotPurge
|| type == OzoneManagerProtocolProtos.Type.CreateSnapshot;
}
```
--
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]