sapienza88 commented on code in PR #823:
URL: https://github.com/apache/incubator-xtable/pull/823#discussion_r3364829722


##########
xtable-utilities/src/main/java/org/apache/xtable/utilities/RunSync.java:
##########
@@ -182,10 +194,47 @@ static void syncTableMetdata(
               .targetTables(targetTables)
               .syncMode(SyncMode.INCREMENTAL)
               .build();
-      try {
-        conversionController.sync(conversionConfig, conversionSourceProvider);
-      } catch (Exception e) {
-        log.error("Error running sync for {}", table.getTableBasePath(), e);
+      if (timeoutInSeconds > 0) {
+        CompletableFuture<Void> syncFuture =
+            CompletableFuture.runAsync(
+                () -> {
+                  conversionController.sync(conversionConfig, 
conversionSourceProvider);
+                },
+                syncExecutor);
+
+        delayer.schedule(
+            () -> {
+              if (!syncFuture.isDone()) {
+                // end complete the future exceptionally with a 
TimeoutException
+                syncFuture.completeExceptionally(
+                    new java.util.concurrent.TimeoutException(
+                        "Sync timed out for " + table.getTableBasePath()));
+                syncFuture.cancel(true); // send interrupt signal to the 
executing worker thread
+              }
+            },
+            timeoutInSeconds,
+            TimeUnit.SECONDS);
+
+        // wait for whichever happens first (completion or timeout exception)
+        try {
+          syncFuture.join();

Review Comment:
   sure thing, some tests are needed..



-- 
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]

Reply via email to