Skip to content

Commit

Permalink
Patch to remove blocking on S3AccessTool
Browse files Browse the repository at this point in the history
This refer to #2339
  • Loading branch information
gvagenas committed Aug 7, 2017
1 parent 879bb7a commit 5fd4fe5
Showing 1 changed file with 29 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,25 @@ public boolean uploadFile(final String fileToUpload) {
logger.info("File to upload to S3: " + fileUri.toString());
}

DateTime start = DateTime.now();
while (!FileUtils.waitFor(file, 30)){}
DateTime end = DateTime.now();
double waitDuration = (end.getMillis() - start.getMillis())/1000;
if (waitDuration > maxDelay || testing) {
if (logger.isInfoEnabled()) {
String msg = String.format("Finished waiting for recording file %s. Wait time %,.2f. Size of file in bytes %s", fileUri.toString(), waitDuration, file.length());
logger.info(msg);
}
}
if (file.exists()) {
//For statistics and logs
DateTime start, end;
double waitDuration;

// if (!file.exists()) {
// start = DateTime.now();
// while (!FileUtils.waitFor(file, 2)) {
// }
// end = DateTime.now();
// waitDuration = (end.getMillis() - start.getMillis()) / 1000;
// if (waitDuration > maxDelay || testing) {
// if (logger.isInfoEnabled()) {
// String msg = String.format("Finished waiting for recording file %s. Wait time %,.2f. Size of file in bytes %s", fileUri.toString(), waitDuration, file.length());
// logger.info(msg);
// }
// }
// }

if (fileExists(file)) {
start = DateTime.now();
if (testing) {
try {
Expand Down Expand Up @@ -167,7 +175,8 @@ public boolean uploadFile(final String fileToUpload) {
}
return true;
} else {
logger.error("Timeout waiting for the recording file: "+file.getAbsolutePath());
String msg = String.format("Recording file \"%s\" doesn't exists ",file.getPath());
logger.error(msg);
return false;
}
} catch (AmazonServiceException ase) {
Expand All @@ -188,6 +197,14 @@ public boolean uploadFile(final String fileToUpload) {
}
}

private boolean fileExists(final File file) {
if (file.exists()) {
return true;
} else {
return FileUtils.waitFor(file, 2);
}
}

public URI getS3Uri(final String fileToUpload) {
if (s3client == null) {
s3client = getS3client();
Expand Down

0 comments on commit 5fd4fe5

Please sign in to comment.