Package me.desair.tus.server.upload.disk
Class DiskLockingService
java.lang.Object
me.desair.tus.server.upload.disk.AbstractDiskBasedService
me.desair.tus.server.upload.disk.DiskLockingService
- All Implemented Interfaces:
UploadLockingService
UploadLockingService
implementation that uses the file system for implementing locking
File locking can also apply to shared network drives. This way the framework supports clustering as long as the upload storage directory is mounted as a shared (network) drive.
File locks are also automatically released on application (JVM) shutdown. This means the file locking is not persistent and prevents cleanup and stale lock issues.
-
Constructor Summary
ConstructorDescriptionDiskLockingService
(String storagePath) DiskLockingService
(UploadIdFactory idFactory, String storagePath) Constructor to use custom UploadIdFactory. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clean up any stale locks that are still present.boolean
Check if the upload with the given ID is currently locked.lockUploadByUri
(String requestUri) If the given URI represents a valid upload, lock that upload for processing.void
setIdFactory
(UploadIdFactory idFactory) Set an instance if IdFactory to be used for creating identities and extracting them from uploadUris.Methods inherited from class me.desair.tus.server.upload.disk.AbstractDiskBasedService
getPathInStorageDirectory, getStoragePath
-
Constructor Details
-
DiskLockingService
-
DiskLockingService
Constructor to use custom UploadIdFactory.
-
-
Method Details
-
lockUploadByUri
Description copied from interface:UploadLockingService
If the given URI represents a valid upload, lock that upload for processing.- Specified by:
lockUploadByUri
in interfaceUploadLockingService
- Parameters:
requestUri
- The URI that potentially represents an upload- Returns:
- The lock on the upload, or null if not lock was applied
- Throws:
TusException
- If the upload is already lockedIOException
-
cleanupStaleLocks
Description copied from interface:UploadLockingService
Clean up any stale locks that are still present.- Specified by:
cleanupStaleLocks
in interfaceUploadLockingService
- Throws:
IOException
- When cleaning a stale lock fails
-
isLocked
Description copied from interface:UploadLockingService
Check if the upload with the given ID is currently locked.- Specified by:
isLocked
in interfaceUploadLockingService
- Parameters:
id
- The ID of the upload to check- Returns:
- True if the upload is locked, false otherwise
-
setIdFactory
Description copied from interface:UploadLockingService
Set an instance if IdFactory to be used for creating identities and extracting them from uploadUris.- Specified by:
setIdFactory
in interfaceUploadLockingService
- Parameters:
idFactory
- TheUploadIdFactory
to use within this locking service
-