Skip to content

Commit

Permalink
avoid repeat failures when server is overloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
qqmyers committed Apr 18, 2023
1 parent a737316 commit 3d8c5cb
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/main/java/org/sead/uploader/dataverse/DVUploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,23 @@ public void addDatasetMetadata(String newSubject, String type, JSONObject relati
protected void postProcessChildren(Resource dir) {
if (!singleFile && directUpload) {
//Have to register all the files in this dir with Dataverse

int retries = 5;
//In case of prior 504 (or other) errors, make sure the dataset is OK before adding files
int total = 0;
// For new servers, wait up to maxWaitTime for a dataset lock to expire.
try {
while (isLocked() && (total < maxWaitTime)) {
TimeUnit.SECONDS.sleep(1);
total = total + 1;
}
} catch(InterruptedException ie) {
println("Error waiting for Dataverse dataset lock - skipping: " + dir.getAbsolutePath());
retries=0;
}

String urlString = server + "/api/datasets/:persistentId/addFiles";
urlString = urlString + "?persistentId=" + datasetPID + "&key=" + apiKey;
int retries = 5;

while (retries > 0) {
HttpPost httppost = new HttpPost(urlString);
JSONArray jsonData = new JSONArray();
Expand Down Expand Up @@ -551,7 +564,7 @@ protected void postProcessChildren(Resource dir) {
}
}
retries = 0;
int total = 0;
total = 0;
// For new servers, wait up to maxWaitTime for a dataset lock to expire.
while (isLocked() && (total < maxWaitTime)) {
TimeUnit.SECONDS.sleep(1);
Expand Down

0 comments on commit 3d8c5cb

Please sign in to comment.