Skip to content

Commit

Permalink
more globus mods (work in progress). #10623
Browse files Browse the repository at this point in the history
  • Loading branch information
landreev committed Aug 12, 2024
1 parent 0495160 commit ba66138
Show file tree
Hide file tree
Showing 7 changed files with 363 additions and 187 deletions.
7 changes: 6 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/api/Datasets.java
Original file line number Diff line number Diff line change
Expand Up @@ -4009,6 +4009,7 @@ public Response addGlobusFilesToDataset(@Context ContainerRequestContext crc,
logger.info(" ==== (api addGlobusFilesToDataset) jsonData ====== " + jsonData);

if (!systemConfig.isHTTPUpload()) {
// @todo why isHTTPUpload()? - shouldn't it be checking isGlobusUpload() here?
return error(Response.Status.SERVICE_UNAVAILABLE, BundleUtil.getStringFromBundle("file.api.httpDisabled"));
}

Expand Down Expand Up @@ -4075,7 +4076,11 @@ public Response addGlobusFilesToDataset(@Context ContainerRequestContext crc,
String requestUrl = SystemConfig.getDataverseSiteUrlStatic();

// Async Call
globusService.globusUpload(jsonObject, token, dataset, requestUrl, authUser);
try {
globusService.globusUpload(jsonObject, token, dataset, requestUrl, authUser);
} catch (IllegalArgumentException ex) {
return badRequest("Invalid parameters: "+ex.getMessage());
}

return ok("Async call to Globus Upload started ");

Expand Down
485 changes: 302 additions & 183 deletions src/main/java/edu/harvard/iq/dataverse/globus/GlobusServiceBean.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package edu.harvard.iq.dataverse.globus;

public class GlobusTask {
/**
* This class is used to store the state of an ongoing Globus task (transfer)
* as reported by the Globus task API.
*/
public class GlobusTaskState {

private String DATA_TYPE;
private String type;
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/globus/GlobusUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,37 @@ public static JsonObject getFilesMap(List<DataFile> dataFiles, Dataset d) {
}
return filesBuilder.build();
}

public static boolean isTaskCompleted(GlobusTaskState task) {
if (task != null) {
String status = task.getStatus();
if (status != null) {
if (status.equalsIgnoreCase("ACTIVE")) {
if (task.getNice_status().equalsIgnoreCase("ok")
|| task.getNice_status().equalsIgnoreCase("queued")) {
return false;
}
}
}
}
return true;
}

public static boolean isTaskSucceeded(GlobusTaskState task) {
String status = null;
if (task != null) {
status = task.getStatus();
if (status != null) {
status = status.toUpperCase();
if (status.equals("ACTIVE") || status.startsWith("FAILED") || status.startsWith("INACTIVE")) {
// There are cases where a failed task may still be showing
// as "ACTIVE". But it is definitely safe to assume that it
// has not completed *successfully*.
return false;
}
return true;
}
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,13 @@ public List<DataFile> saveAndAddFilesToDataset(DatasetVersion version,
StorageIO<DvObject> dataAccess = DataAccess.getStorageIO(dataFile);
//Populate metadata
dataAccess.open(DataAccessOption.READ_ACCESS);

// (this will make a remote call to check if the file exists
// and obtain its size)
confirmedFileSize = dataAccess.getSize();

// For directly-uploaded files, we will perform the file size
// limit and quota checks here. Perform them *again*, in
// some cases: a directly uploaded files have already been
// some cases: files directly uploaded via the UI have already been
// checked (for the sake of being able to reject the upload
// before the user clicks "save"). But in case of direct
// uploads via API, these checks haven't been performed yet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ public enum FeatureFlags {
* @since Dataverse 6.3
*/
DISABLE_RETURN_TO_AUTHOR_REASON("disable-return-to-author-reason"),
/**
* TEMPORARY feature flag for the new Globus upload framework (will only be
* used for testing).
*/
GLOBUS_USE_EXPERIMENTAL_ASYNC_FRAMEWORK("globus-use-experimental-async-framework"),
;

final String flag;
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class SystemConfig {
private String buildNumber = null;

private static final String JVM_TIMER_SERVER_OPTION = "dataverse.timerServer";
private static final String JVM_GLOBUS_TASK_MONITORING_OPTION = "dataverse.globus.taskMonitoringServer";

private static final long DEFAULT_GUESTBOOK_RESPONSES_DISPLAY_LIMIT = 5000L;
private static final long DEFAULT_THUMBNAIL_SIZE_LIMIT_IMAGE = 3000000L; // 3 MB
Expand Down Expand Up @@ -545,6 +546,14 @@ public boolean isTimerServer() {
}
return false;
}

public boolean isGlobusTaskMonitoringServer() {
String optionValue = System.getProperty(JVM_GLOBUS_TASK_MONITORING_OPTION);
if ("true".equalsIgnoreCase(optionValue)) {
return true;
}
return false;
}

public String getFooterCopyrightAndYear() {
return BundleUtil.getStringFromBundle("footer.copyright", Arrays.asList(Year.now().getValue() + ""));
Expand Down

0 comments on commit ba66138

Please sign in to comment.