public abstract class Lockable<T extends Lockable<T>> extends Keyed<T>
Job
s, to prevent
overwriting in-use keys. E.g. model-building: expected to read-lock input
Frame
s, and write-lock the output Model
.
Parser should write-lock the output Frame, to guard against double-parsing.
This is a simple cooperative distributed locking scheme. Because we need
distributed locking, the normal Java locks do not work. Because
we cannot enforce good behavior, this is a cooperative scheme
only.
Supports: Keyed.BinarySerializer<X extends Keyed>
Modifier and Type | Field and Description |
---|---|
Key[] |
_lockers
List of Job Keys locking this Key.
|
_key, EMPTY_KEY_LIST
Constructor and Description |
---|
Lockable(Key key)
Create a Lockable object, if it has a
Key . |
Modifier and Type | Method and Description |
---|---|
T |
delete_and_lock(Key job_key)
Write-lock
this._key by job_key , and delete any prior mapping. |
void |
delete()
Write-lock 'this' and delete; blocking.
|
static void |
delete(Key key)
Write-lock key and delete; blocking.
|
Futures |
delete(Key job_key,
Futures fs)
Write-lock 'this' and delete.
|
void |
read_lock(Key job_key)
Atomically get a read-lock on this, preventing future deletes or updates
|
static void |
read_lock(Key k,
Key job_key)
Atomically get a read-lock on Key k, preventing future deletes or updates
|
void |
unlock_all()
Force-unlock (break a lock) all lockers; useful in some debug situations.
|
void |
unlock(Key job_key)
Atomically set a new version of self and unlock.
|
T |
update(Key job_key)
Atomically set a new version of self, without changing the locking.
|
Lockable |
write_lock(Key job_key)
Write-lock
this._key by job_key . |
checksum_impl, checksum, getBinarySerializer, getPublishedKeys, remove_impl, remove, remove, remove, remove
clone, frozenType, read_impl, read, readExternal, readJSON_impl, readJSON, toJsonString, write_impl, write, writeExternal, writeHTML_impl, writeHTML, writeJSON_impl, writeJSON
public transient Key[] _lockers
_lockers[0 ]
. Can be null locker._lockers[1+]
.public Lockable write_lock(Key job_key)
this._key
by job_key
.
Throws IAE if the Key is already locked.public T delete_and_lock(Key job_key)
this._key
by job_key
, and delete any prior mapping.
Throws IAE if the Key is already locked.public static void delete(Key key)
public void delete()
public Futures delete(Key job_key, Futures fs)
public static void read_lock(Key k, Key job_key)
public void read_lock(Key job_key)
public T update(Key job_key)
public void unlock(Key job_key)
public void unlock_all()