[storage-aws] force upload progress updates to strick sequence
Prevents the situation where a second progress update arrives while the first is still on the process of being processed. The new update is blocked until the first is completed.
This commit is contained in:
parent
e0beef9d73
commit
242804294d
1 changed files with 5 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
||||||
package net.kemitix.thorp.storage.aws
|
package net.kemitix.thorp.storage.aws
|
||||||
|
|
||||||
|
import java.util.concurrent.locks.StampedLock
|
||||||
|
|
||||||
import com.amazonaws.event.ProgressEventType.RESPONSE_BYTE_TRANSFER_EVENT
|
import com.amazonaws.event.ProgressEventType.RESPONSE_BYTE_TRANSFER_EVENT
|
||||||
import com.amazonaws.event.{ProgressEvent, ProgressListener}
|
import com.amazonaws.event.{ProgressEvent, ProgressListener}
|
||||||
import com.amazonaws.services.s3.model.{ObjectMetadata, PutObjectRequest}
|
import com.amazonaws.services.s3.model.{ObjectMetadata, PutObjectRequest}
|
||||||
|
@ -75,8 +77,11 @@ trait Uploader {
|
||||||
listenerSettings =>
|
listenerSettings =>
|
||||||
new ProgressListener {
|
new ProgressListener {
|
||||||
private val listener = UploadEventListener.listener(listenerSettings)
|
private val listener = UploadEventListener.listener(listenerSettings)
|
||||||
|
private val lock = new StampedLock
|
||||||
override def progressChanged(progressEvent: ProgressEvent): Unit = {
|
override def progressChanged(progressEvent: ProgressEvent): Unit = {
|
||||||
|
val writeLock = lock.writeLock()
|
||||||
listener(eventHandler(progressEvent))
|
listener(eventHandler(progressEvent))
|
||||||
|
lock.unlock(writeLock)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def eventHandler: ProgressEvent => UploadEvent =
|
private def eventHandler: ProgressEvent => UploadEvent =
|
||||||
|
|
Loading…
Reference in a new issue