Named Locks
Named locks are essentially locks that are assigned to some given (opaque) ID. If you work with multiple resources that each can have unique ID assigned (i.e., file with an absolute path, some entities with unique ID), then you can use named locks to make sure they are being protected from concurrent read and write actions.
Named locks provide support classes for implementations, and provide out of the box seven named lock implementations and three name mappers.
Out of the box, “local” (local to JVM) named lock implementations are the following:
rwlock-local
implemented inorg.eclipse.aether.named.providers.LocalReadWriteLockNamedLockFactory
that uses JVMjava.util.concurrent.locks.ReentrantReadWriteLock
.semaphore-local
implemented inorg.eclipse.aether.named.providers.LocalSemaphoreNamedLockFactory
that uses JVMjava.util.concurrent.Semaphore
.file-lock
implemented inorg.eclipse.aether.named.providers.FileLockNamedLockFactory
that uses JVMjava.nio.channels.FileLock
.noop
implemented inorg.eclipse.aether.named.providers.NoopNamedLockFactory
that uses no locking.
Out of the box, “distributed” named lock implementations are the following (separate modules which require additional dependencies):
rwlock-redisson
implemented inorg.eclipse.aether.named.redisson.RedissonReadWriteLockNamedLockFactory
.semaphore-redisson
implemented inorg.eclipse.aether.named.redisson.RedissonSemaphoreNamedLockFactory
.semaphore-hazelcast-client
implemented inorg.eclipse.aether.named.hazelcast.HazelcastClientCPSemaphoreNamedLockFactory
.semaphore-hazelcast
implemented inorg.eclipse.aether.named.hazelcast.HazelcastCPSemaphoreNamedLockFactory
.
Local named locks are only suited within one JVM with a multithreaded build. Sharing a local repository between multiple Maven processes (i.e., on a busy CI server) requires a distributed named lock!
The aforementioned (opaque) IDs need to be mapped from artifacts and metadata.
Out of the box, name mapper implementations are the following:
static
implemented inorg.eclipse.aether.internal.impl.synccontext.named.StaticNameMapper
.gav
implemented inorg.eclipse.aether.internal.impl.synccontext.named.GAVNameMapper
.discriminating
implemented inorg.eclipse.aether.internal.impl.synccontext.named.DiscriminatingNameMapper
.file-gav
implemented inorg.eclipse.aether.internal.impl.synccontext.named.FileGAVNameMapper
.