Skip to content

Commit

Permalink
fix timeouts, use addFiles call for remote reference case
Browse files Browse the repository at this point in the history
  • Loading branch information
qqmyers committed Nov 22, 2023
1 parent 5ee1905 commit c6ff2c7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions src/main/java/edu/harvard/iq/dataverse/api/Datasets.java
Original file line number Diff line number Diff line change
Expand Up @@ -3599,25 +3599,32 @@ public Response getGlobusUploadParams(@Context ContainerRequestContext crc, @Pat
} else {
params.add("referenceEndpointsWithPaths", referenceEndpointsWithPaths);
}
int timeoutSeconds = JvmSettings.GLOBUS_RULES_CACHE_MAXAGE.lookup(Integer.class) * 60;
int timeoutSeconds = JvmSettings.GLOBUS_RULES_CACHE_MAXAGE.lookup(Integer.class);
JsonArrayBuilder allowedApiCalls = Json.createArrayBuilder();
String requestCallName = managed ? "requestGlobusTransferPaths" : "requestGlobusReferencePaths";
allowedApiCalls.add(
Json.createObjectBuilder().add(URLTokenUtil.NAME, requestCallName).add(URLTokenUtil.HTTP_METHOD, "POST")
.add(URLTokenUtil.URL_TEMPLATE, "/api/v1/datasets/{datasetId}/requestGlobusUploadPaths")
.add(URLTokenUtil.TIMEOUT, timeoutSeconds));
if(managed) {
allowedApiCalls.add(Json.createObjectBuilder().add(URLTokenUtil.NAME, "addGlobusFiles")
.add(URLTokenUtil.HTTP_METHOD, "POST")
.add(URLTokenUtil.URL_TEMPLATE, "/api/v1/datasets/{datasetId}/addGlobusFiles")
.add(URLTokenUtil.TIMEOUT, timeoutSeconds));
} else {
allowedApiCalls.add(Json.createObjectBuilder().add(URLTokenUtil.NAME, "addFiles")
.add(URLTokenUtil.HTTP_METHOD, "POST")
.add(URLTokenUtil.URL_TEMPLATE, "/api/v1/datasets/{datasetId}/addFiles")
.add(URLTokenUtil.TIMEOUT, timeoutSeconds));
}
allowedApiCalls.add(Json.createObjectBuilder().add(URLTokenUtil.NAME, "getDatasetMetadata")
.add(URLTokenUtil.HTTP_METHOD, "GET")
.add(URLTokenUtil.URL_TEMPLATE, "/api/v1/datasets/{datasetId}/versions/{datasetVersion}")
.add(URLTokenUtil.TIMEOUT, 300));
.add(URLTokenUtil.TIMEOUT, 5));
allowedApiCalls.add(
Json.createObjectBuilder().add(URLTokenUtil.NAME, "getFileListing").add(URLTokenUtil.HTTP_METHOD, "GET")
.add(URLTokenUtil.URL_TEMPLATE, "/api/v1/datasets/{datasetId}/versions/{datasetVersion}/files")
.add(URLTokenUtil.TIMEOUT, 300));
.add(URLTokenUtil.TIMEOUT, 5));

return ok(tokenUtil.createPostBody(params.build(), allowedApiCalls.build()));
}
Expand Down Expand Up @@ -3783,7 +3790,7 @@ public Response getGlobusDownloadParams(@Context ContainerRequestContext crc, @P
params.add("endpoint", transferEndpoint);
}
params.add("files", files);
int timeoutSeconds = JvmSettings.GLOBUS_RULES_CACHE_MAXAGE.lookup(Integer.class) * 60;
int timeoutSeconds = JvmSettings.GLOBUS_RULES_CACHE_MAXAGE.lookup(Integer.class);
JsonArrayBuilder allowedApiCalls = Json.createArrayBuilder();
allowedApiCalls.add(Json.createObjectBuilder().add(URLTokenUtil.NAME, "monitorGlobusDownload")
.add(URLTokenUtil.HTTP_METHOD, "POST")
Expand All @@ -3797,11 +3804,11 @@ public Response getGlobusDownloadParams(@Context ContainerRequestContext crc, @P
allowedApiCalls.add(Json.createObjectBuilder().add(URLTokenUtil.NAME, "getDatasetMetadata")
.add(URLTokenUtil.HTTP_METHOD, "GET")
.add(URLTokenUtil.URL_TEMPLATE, "/api/v1/datasets/{datasetId}/versions/{datasetVersion}")
.add(URLTokenUtil.TIMEOUT, 300));
.add(URLTokenUtil.TIMEOUT, 5));
allowedApiCalls.add(
Json.createObjectBuilder().add(URLTokenUtil.NAME, "getFileListing").add(URLTokenUtil.HTTP_METHOD, "GET")
.add(URLTokenUtil.URL_TEMPLATE, "/api/v1/datasets/{datasetId}/versions/{datasetVersion}/files")
.add(URLTokenUtil.TIMEOUT, 300));
.add(URLTokenUtil.TIMEOUT, 5));

return ok(tokenUtil.createPostBody(params.build(), allowedApiCalls.build()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ static class MakeRequestResponse {
// Single cache of open rules/permission requests
private final Cache<String, JsonObject> downloadCache = Caffeine.newBuilder()
.expireAfterWrite(
Duration.of(JvmSettings.GLOBUS_RULES_CACHE_MAXAGE.lookup(Integer.class) + 300, ChronoUnit.MINUTES))
Duration.of(JvmSettings.GLOBUS_RULES_CACHE_MAXAGE.lookup(Integer.class) + 5, ChronoUnit.MINUTES))
.scheduler(Scheduler.systemScheduler()).evictionListener((downloadId, datasetId, cause) -> {
// Delete downloads that expire
logger.info("Download for " + downloadId + " expired");
Expand Down

0 comments on commit c6ff2c7

Please sign in to comment.