Skip to content

Commit

Permalink
Optionally synchronize upload on S3 by property 'synchronizeUpload=tr…
Browse files Browse the repository at this point in the history
…ue' #1710
  • Loading branch information
vrindanayak committed Nov 29, 2018
1 parent 75717be commit ddf09e5
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ protected void afterOutputStreamClosed(WriteContext ctx) throws IOException {
}

private void upload(WriteContext ctx, InputStream in) throws IOException {
if (isSynchronizeUpload())
synchronized (descriptor) {
upload(in, ctx);
}
else
upload(in, ctx);
}

private void upload(InputStream in, WriteContext ctx) throws IOException {
BlobStore blobStore = context.getBlobStore();
String storagePath = pathFormat.format(ctx.getAttributes());
if (count++ == 0 && !blobStore.containerExists(container))
Expand All @@ -180,6 +189,10 @@ private void upload(WriteContext ctx, InputStream in) throws IOException {
ctx.setStoragePath(storagePath);
}

private boolean isSynchronizeUpload() {
return "true".equals(descriptor.getProperty("synchronizeUpload", "false"));
}

@Override
protected InputStream openInputStreamA(ReadContext ctx) throws IOException {
BlobStore blobStore = context.getBlobStore();
Expand Down

0 comments on commit ddf09e5

Please sign in to comment.