Skip to content

Commit

Permalink
cleanup #10623
Browse files Browse the repository at this point in the history
  • Loading branch information
landreev committed Aug 13, 2024
1 parent 4080341 commit e086a60
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ private void processUploadedFiles(JsonArray filesJsonArray, Dataset dataset, Aut
* @throws ExecutionException
* @throws InterruptedException
*/
/*
public String addFilesAsync(String curlCommand, Logger globusLogger)
throws ExecutionException, InterruptedException {
CompletableFuture<String> addFilesFuture = CompletableFuture.supplyAsync(() -> {
Expand Down Expand Up @@ -1018,7 +1019,7 @@ private String addFiles(String curlCommand, Logger globusLogger) {
}
return status;
}
} */

@Asynchronous
public void globusDownload(String jsonData, Dataset dataset, User authUser) throws MalformedURLException {
Expand Down Expand Up @@ -1431,4 +1432,10 @@ public void addFilesOnSuccess(GlobusTaskInProgress globusTask) {
// method above).
}
}

public void deleteExternalUploadRecords(String taskId) {
em.createNamedQuery("ExternalFileUploadInProgress.deleteByTaskId")
.setParameter("taskId", taskId)
.executeUpdate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import jakarta.enterprise.concurrent.ManagedScheduledExecutorService;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

/**
*
Expand All @@ -30,6 +31,8 @@
@Singleton
@Startup
public class TaskMonitoringServiceBean {
private static final Logger logger = Logger.getLogger("edu.harvard.iq.dataverse.globus.TaskMonitoringServiceBean");

@Resource
ManagedScheduledExecutorService scheduler;

Expand All @@ -43,11 +46,14 @@ public class TaskMonitoringServiceBean {
@PostConstruct
public void init() {
if (systemConfig.isGlobusTaskMonitoringServer()) {
logger.info("Starting Globus task monitoring service");
int pollingInterval = SystemConfig.getIntLimitFromStringOrDefault(
settingsSvc.getValueForKey(SettingsServiceBean.Key.GlobusPollingInterval), 60);
this.scheduler.scheduleAtFixedRate(this::checkOngoingTasks,
0, pollingInterval,
TimeUnit.SECONDS);
} else {
logger.info("Skipping Globus task monitor initialization");
}
}

Expand All @@ -57,6 +63,7 @@ public void init() {
* @todo make sure the executions do not overlap/stack up
*/
public void checkOngoingTasks() {
logger.info("Performing a scheduled external Globus task check");
List<GlobusTaskInProgress> tasks = globusService.findAllOngoingTasks();

tasks.forEach(t -> {
Expand All @@ -69,6 +76,7 @@ public void checkOngoingTasks() {
// Whether it finished successfully, or failed in the process,
// there's no need to keep monitoring this task, so we can
// delete it.
globusService.deleteExternalUploadRecords(t.getTaskId());
globusService.deleteTask(t);
// @todo double-check that the locks have been properly handled
}
Expand Down

0 comments on commit e086a60

Please sign in to comment.