ptlrs commented on code in PR #8363:
URL: https://github.com/apache/ozone/pull/8363#discussion_r2096792457
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/ReplicasVerify.java:
##########
@@ -67,21 +96,59 @@ public class ReplicasVerify extends Handler {
@CommandLine.ArgGroup(exclusive = false, multiplicity = "1")
private Verification verification;
- private List<ReplicaVerifier> replicaVerifiers;
+ @CommandLine.Option(names = "--threads",
+ description = "Number of threads to use for verification",
+ defaultValue = "10")
+ private int threadCount;
+
+ private ExecutorService verificationExecutor;
+ private ExecutorService writerExecutor;
+ private ThreadLocal<List<ReplicaVerifier>> threadLocalVerifiers;
+ private List<CompletableFuture<Void>> allFutures;
+
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper()
+ .configure(SerializationFeature.INDENT_OUTPUT, true);
+ private static final ObjectWriter WRITER = OBJECT_MAPPER.writer();
@Override
protected void execute(OzoneClient client, OzoneAddress address) throws
IOException {
- replicaVerifiers = new ArrayList<>();
-
- if (verification.doExecuteChecksums) {
- replicaVerifiers.add(new ChecksumVerifier(getConf()));
- }
+ allFutures = new ArrayList<>();
+ verificationExecutor = Executors.newFixedThreadPool(threadCount);
+ writerExecutor = Executors.newSingleThreadExecutor();
+ threadLocalVerifiers = ThreadLocal.withInitial(() -> {
+ List<ReplicaVerifier> verifiers = new ArrayList<>();
+ try {
+ if (verification.doExecuteChecksums) {
+ verifiers.add(new ChecksumVerifier(getConf()));
+ }
- if (verification.doExecuteBlockExistence) {
- replicaVerifiers.add(new BlockExistenceVerifier(getConf()));
+ if (verification.doExecuteBlockExistence) {
+ verifiers.add(new BlockExistenceVerifier(getConf()));
+ }
+ } catch (IOException e) {
+ LOG.error("Error initializing verifiers", e);
+ throw new RuntimeException("Error initializing verifiers", e);
+ }
+ return verifiers;
+ });
+
+ try {
+ createOutputDirectory();
+ findCandidateKeys(client, address);
Review Comment:
The finally clause is there to ensure clean up resources.
--
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]