DomGarguilo commented on code in PR #4207:
URL: https://github.com/apache/accumulo/pull/4207#discussion_r1479995716
##########
server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java:
##########
@@ -83,13 +85,17 @@ public class GarbageCollectWriteAheadLogs {
this.fs = fs;
this.liveServers = liveServers;
this.walMarker = new WalStateManager(context);
- this.store = () -> Iterators.concat(
- context.getAmple().readTablets().forLevel(DataLevel.ROOT).filter(new
HasWalsFilter())
- .fetch(LOCATION, LAST, LOGS, PREV_ROW, SUSPEND).build().iterator(),
-
context.getAmple().readTablets().forLevel(DataLevel.METADATA).filter(new
HasWalsFilter())
- .fetch(LOCATION, LAST, LOGS, PREV_ROW, SUSPEND).build().iterator(),
- context.getAmple().readTablets().forLevel(DataLevel.USER).filter(new
HasWalsFilter())
- .fetch(LOCATION, LAST, LOGS, PREV_ROW,
SUSPEND).build().iterator());
+ TabletsMetadata root =
context.getAmple().readTablets().forLevel(DataLevel.ROOT)
+ .filter(new HasWalsFilter()).fetch(LOCATION, LAST, LOGS, PREV_ROW,
SUSPEND).build();
+ TabletsMetadata metadata =
context.getAmple().readTablets().forLevel(DataLevel.METADATA)
+ .filter(new HasWalsFilter()).fetch(LOCATION, LAST, LOGS, PREV_ROW,
SUSPEND).build();
+ TabletsMetadata user =
context.getAmple().readTablets().forLevel(DataLevel.USER)
+ .filter(new HasWalsFilter()).fetch(LOCATION, LAST, LOGS, PREV_ROW,
SUSPEND).build();
+ this.store = Streams.concat(root.stream(), metadata.stream(),
user.stream()).onClose(() -> {
Review Comment:
Another option could be to keep things the same (using the iterators as the
underlying resource for `store`) then make `GarbageCollectWriteAheadLogs`
autoclosable and make sure the resources are tracked and closed when the object
is. Then we could do something like this:
```diff
- GarbageCollectWriteAheadLogs walogCollector =
- new GarbageCollectWriteAheadLogs(getContext(), fs,
liveTServerSet);
- log.info("Beginning garbage collection of write-ahead logs");
- walogCollector.collect(status);
+ try(GarbageCollectWriteAheadLogs walogCollector =
+ new GarbageCollectWriteAheadLogs(getContext(), fs,
liveTServerSet)) {
+ log.info("Beginning garbage collection of write-ahead logs");
+ walogCollector.collect(status);
+ }
```
--
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]