1 package org.sourceforge.jemm.database.components.se;
2
3 import java.util.Set;
4
5 import org.sourceforge.jemm.database.ClientId;
6 import org.sourceforge.jemm.database.ClientThreadId;
7 import org.sourceforge.jemm.database.components.ClientThreadIdRef;
8 import org.sourceforge.jemm.database.components.UserLockInfo;
9 import org.sourceforge.jemm.types.ID;
10
11 /**
12 * Storage interface for user lock management.
13 * <P/>
14 * <B>N.b.</B> The caller is responsible for synchronising access to the user lock info and
15 * client lock information (normally using a lock manager).
16 *
17 * @author Rory Graves
18 */
19 public interface StorageEngineUserLockIF {
20
21 /**
22 * Retrieve the user lock information (lock queue) for the given id.
23 * @param id The id of the lock object.
24 * @return The lock information for the given object.
25 */
26 UserLockInfo getLockInfo(ID id);
27
28 /**
29 * Save an updated lock information.
30 * @param info The update lock information to save.
31 */
32 void saveLockInfo(UserLockInfo info);
33
34 /**
35 * Clear all lock information. This includes both UserLockInfo instances and
36 * client lock information. This is generally performed at startup to ensure
37 * any old locks from previous sessions have been removed.
38 */
39 void clearAll();
40
41 /**
42 * Add a reference from a client to the given object.
43 * @param clientId The target client thread
44 * @param objectId The object being referenced.
45 */
46 void addClientLockReference(ClientThreadId clientId,ID objectId);
47
48 /**
49 * Remove a reference from a client to the given object.
50 * @param clientId The target client.
51 * @param objectId The object being referenced.
52 */
53 void removeClientLockReference(ClientThreadId clientId,ID objectId);
54
55 /**
56 * Return a set of client-threads -> ids for the given client, this is the
57 * list of objects the given client is attempting to lock, or has a lock on.
58 * @param clientId The target client id.
59 * @return The set of ids and client threads which are attempting to
60 * acquire them for the given client.
61 */
62 Set<ClientThreadIdRef> getClientLockSet(ClientId clientId);
63 }