yihua commented on code in PR #11080:
URL: https://github.com/apache/hudi/pull/11080#discussion_r1580033118
##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/streamer/StreamSync.java:
##########
@@ -1026,27 +1026,32 @@ public void runMetaSync() {
Map<String, HoodieException> failedMetaSyncs = new HashMap<>();
for (String impl : syncClientToolClasses) {
Timer.Context syncContext = metrics.getMetaSyncTimerContext();
- boolean success = false;
+ Option<HoodieMetaSyncException> metaSyncException = Option.empty();
try {
SyncUtilHelpers.runHoodieMetaSync(impl.trim(), metaProps, conf, fs,
cfg.targetBasePath, cfg.baseFileFormat);
- success = true;
} catch (HoodieMetaSyncException e) {
- LOG.error("SyncTool class {} failed with exception {}", impl.trim(),
e);
- failedMetaSyncs.put(impl, e);
- }
- long metaSyncTimeNanos = syncContext != null ? syncContext.stop() : 0;
- metrics.updateStreamerMetaSyncMetrics(getSyncClassShortName(impl),
metaSyncTimeNanos);
- if (success) {
- long timeMs = metaSyncTimeNanos / 1000000L;
- LOG.info("[MetaSync] SyncTool class {} completed successfully and
took {} s {} ms ", impl.trim(), timeMs / 1000L, timeMs % 1000L);
+ metaSyncException = Option.of(e);
}
+ logMetaSync(impl, syncContext, failedMetaSyncs, metaSyncException);
}
if (!failedMetaSyncs.isEmpty()) {
throw getHoodieMetaSyncException(failedMetaSyncs);
}
}
}
+ private void logMetaSync(String impl, Timer.Context syncContext, Map<String,
HoodieException> failedMetaSyncs, Option<HoodieMetaSyncException>
metaSyncException) {
+ long metaSyncTimeNanos = syncContext != null ? syncContext.stop() : 0;
+ metrics.updateStreamerMetaSyncMetrics(getSyncClassShortName(impl),
metaSyncTimeNanos);
+ long timeMs = metaSyncTimeNanos / 1000000L;
+ if (metaSyncException.isPresent()) {
+ LOG.error("[MetaSync] SyncTool class {} failed with exception {} and
took {} s {} ms ", impl.trim(), metaSyncException.get(), timeMs / 1000L, timeMs
% 1000L);
Review Comment:
nit: extract the part `took {} s {} ms` out of if-else branch
--
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]