public class DiskLockingService extends AbstractDiskBasedService implements 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 and Description |
|---|
DiskLockingService(String storagePath) |
DiskLockingService(UploadIdFactory idFactory,
String storagePath) |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanupStaleLocks()
Clean up any stale locks that are still present
|
boolean |
isLocked(UploadId id)
Check if the upload with the given ID is currently locked
|
UploadLock |
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
|
getPathInStorageDirectory, getStoragePathpublic DiskLockingService(String storagePath)
public DiskLockingService(UploadIdFactory idFactory, String storagePath)
public UploadLock lockUploadByUri(String requestURI) throws TusException, IOException
UploadLockingServicelockUploadByUri in interface UploadLockingServicerequestURI - The URI that potentially represents an uploadTusException - If the upload is already lockedIOExceptionpublic void cleanupStaleLocks()
throws IOException
UploadLockingServicecleanupStaleLocks in interface UploadLockingServiceIOExceptionpublic boolean isLocked(UploadId id)
UploadLockingServiceisLocked in interface UploadLockingServiceid - The ID of the upload to checkpublic void setIdFactory(UploadIdFactory idFactory)
UploadLockingServicesetIdFactory in interface UploadLockingServiceidFactory - The UploadIdFactory to use within this locking serviceCopyright © 2019. All rights reserved.