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
ConstructorsConstructorDescriptionDiskLockingService(String storagePath) DiskLockingService(UploadIdFactory idFactory, String storagePath) Constructor to use custom UploadIdFactory. -
Method Summary
Modifier and TypeMethodDescriptionvoidClean up any stale locks that are still present.booleanCheck 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.voidsetIdFactory(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:UploadLockingServiceIf the given URI represents a valid upload, lock that upload for processing.- Specified by:
lockUploadByUriin 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:UploadLockingServiceClean up any stale locks that are still present.- Specified by:
cleanupStaleLocksin interfaceUploadLockingService- Throws:
IOException- When cleaning a stale lock fails
-
isLocked
Description copied from interface:UploadLockingServiceCheck if the upload with the given ID is currently locked.- Specified by:
isLockedin interfaceUploadLockingService- Parameters:
id- The ID of the upload to check- Returns:
- True if the upload is locked, false otherwise
-
setIdFactory
Description copied from interface:UploadLockingServiceSet an instance if IdFactory to be used for creating identities and extracting them from uploadUris.- Specified by:
setIdFactoryin interfaceUploadLockingService- Parameters:
idFactory- TheUploadIdFactoryto use within this locking service
-