mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Use a single read-write lock for the DB - don't optimise prematurely.
This commit is contained in:
@@ -38,29 +38,22 @@ import org.briarproject.api.transport.TemporarySecret;
|
|||||||
* terminated by calling either {@link #abortTransaction(T)} or
|
* terminated by calling either {@link #abortTransaction(T)} or
|
||||||
* {@link #commitTransaction(T)}, even if an exception is thrown.
|
* {@link #commitTransaction(T)}, even if an exception is thrown.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking is provided by the DatabaseComponent implementation. To prevent
|
* Read-write locking is provided by the DatabaseComponent implementation.
|
||||||
* deadlock, locks must be acquired in the following (alphabetical) order:
|
|
||||||
* <ul>
|
|
||||||
* <li> contact
|
|
||||||
* <li> identity
|
|
||||||
* <li> message
|
|
||||||
* <li> retention
|
|
||||||
* <li> setting
|
|
||||||
* <li> subscription
|
|
||||||
* <li> transport
|
|
||||||
* <li> window
|
|
||||||
* </ul>
|
|
||||||
* If table A has a foreign key pointing to table B, we get a read lock on A to
|
|
||||||
* read A, a write lock on A to write A, and write locks on A and B to write B.
|
|
||||||
*/
|
*/
|
||||||
interface Database<T> {
|
interface Database<T> {
|
||||||
|
|
||||||
/** Opens the database and returns true if the database already existed. */
|
/**
|
||||||
|
* Opens the database and returns true if the database already existed.
|
||||||
|
* <p>
|
||||||
|
* Locking: write.
|
||||||
|
*/
|
||||||
boolean open() throws DbException, IOException;
|
boolean open() throws DbException, IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevents new transactions from starting, waits for all current
|
* Prevents new transactions from starting, waits for all current
|
||||||
* transactions to finish, and closes the database.
|
* transactions to finish, and closes the database.
|
||||||
|
* <p>
|
||||||
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void close() throws DbException, IOException;
|
void close() throws DbException, IOException;
|
||||||
|
|
||||||
@@ -92,8 +85,7 @@ interface Database<T> {
|
|||||||
* Stores a contact associated with the given local and remote pseudonyms,
|
* Stores a contact associated with the given local and remote pseudonyms,
|
||||||
* and returns an ID for the contact.
|
* and returns an ID for the contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: contact write, message write, retention write,
|
* Locking: write.
|
||||||
* subscription write, transport write, window write.
|
|
||||||
*/
|
*/
|
||||||
ContactId addContact(T txn, Author remote, AuthorId local)
|
ContactId addContact(T txn, Author remote, AuthorId local)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -101,7 +93,7 @@ interface Database<T> {
|
|||||||
/**
|
/**
|
||||||
* Stores an endpoint.
|
* Stores an endpoint.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: window write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void addEndpoint(T txn, Endpoint ep) throws DbException;
|
void addEndpoint(T txn, Endpoint ep) throws DbException;
|
||||||
|
|
||||||
@@ -109,29 +101,28 @@ interface Database<T> {
|
|||||||
* Subscribes to a group, or returns false if the user already has the
|
* Subscribes to a group, or returns false if the user already has the
|
||||||
* maximum number of subscriptions.
|
* maximum number of subscriptions.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message write, subscription write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
boolean addGroup(T txn, Group g) throws DbException;
|
boolean addGroup(T txn, Group g) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores a local pseudonym.
|
* Stores a local pseudonym.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: contact write, identity write, message write, retention write,
|
* Locking: write.
|
||||||
* subscription write, transport write, window write.
|
|
||||||
*/
|
*/
|
||||||
void addLocalAuthor(T txn, LocalAuthor a) throws DbException;
|
void addLocalAuthor(T txn, LocalAuthor a) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores a message.
|
* Stores a message.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void addMessage(T txn, Message m, boolean local) throws DbException;
|
void addMessage(T txn, Message m, boolean local) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Records that a message has been offered by the given contact.
|
* Records that a message has been offered by the given contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void addOfferedMessage(T txn, ContactId c, MessageId m) throws DbException;
|
void addOfferedMessage(T txn, ContactId c, MessageId m) throws DbException;
|
||||||
|
|
||||||
@@ -139,7 +130,7 @@ interface Database<T> {
|
|||||||
* Stores the given temporary secrets and deletes any secrets that have
|
* Stores the given temporary secrets and deletes any secrets that have
|
||||||
* been made obsolete.
|
* been made obsolete.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: window write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void addSecrets(T txn, Collection<TemporarySecret> secrets)
|
void addSecrets(T txn, Collection<TemporarySecret> secrets)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -147,10 +138,10 @@ interface Database<T> {
|
|||||||
/**
|
/**
|
||||||
* Initialises the status of the given message with respect to the given
|
* Initialises the status of the given message with respect to the given
|
||||||
* contact.
|
* contact.
|
||||||
|
* <p>
|
||||||
|
* Locking: write.
|
||||||
* @param ack whether the message needs to be acknowledged.
|
* @param ack whether the message needs to be acknowledged.
|
||||||
* @param seen whether the contact has seen the message.
|
* @param seen whether the contact has seen the message.
|
||||||
* <p>
|
|
||||||
* Locking: message write.
|
|
||||||
*/
|
*/
|
||||||
void addStatus(T txn, ContactId c, MessageId m, boolean ack, boolean seen)
|
void addStatus(T txn, ContactId c, MessageId m, boolean ack, boolean seen)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -159,7 +150,7 @@ interface Database<T> {
|
|||||||
* Stores a transport and returns true if the transport was not previously
|
* Stores a transport and returns true if the transport was not previously
|
||||||
* in the database.
|
* in the database.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: transport write, window write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
boolean addTransport(T txn, TransportId t, long maxLatency)
|
boolean addTransport(T txn, TransportId t, long maxLatency)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -167,49 +158,49 @@ interface Database<T> {
|
|||||||
/**
|
/**
|
||||||
* Makes a group visible to the given contact.
|
* Makes a group visible to the given contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: subscription write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void addVisibility(T txn, ContactId c, GroupId g) throws DbException;
|
void addVisibility(T txn, ContactId c, GroupId g) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the database contains the given contact.
|
* Returns true if the database contains the given contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: contact read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
boolean containsContact(T txn, AuthorId a) throws DbException;
|
boolean containsContact(T txn, AuthorId a) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the database contains the given contact.
|
* Returns true if the database contains the given contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: contact read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
boolean containsContact(T txn, ContactId c) throws DbException;
|
boolean containsContact(T txn, ContactId c) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the user subscribes to the given group.
|
* Returns true if the user subscribes to the given group.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: subscription read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
boolean containsGroup(T txn, GroupId g) throws DbException;
|
boolean containsGroup(T txn, GroupId g) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the database contains the given local pseudonym.
|
* Returns true if the database contains the given local pseudonym.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: identity read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
boolean containsLocalAuthor(T txn, AuthorId a) throws DbException;
|
boolean containsLocalAuthor(T txn, AuthorId a) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the database contains the given message.
|
* Returns true if the database contains the given message.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
boolean containsMessage(T txn, MessageId m) throws DbException;
|
boolean containsMessage(T txn, MessageId m) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the database contains the given transport.
|
* Returns true if the database contains the given transport.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: transport read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
boolean containsTransport(T txn, TransportId t) throws DbException;
|
boolean containsTransport(T txn, TransportId t) throws DbException;
|
||||||
|
|
||||||
@@ -217,7 +208,7 @@ interface Database<T> {
|
|||||||
* Returns true if the user subscribes to the given group and the group is
|
* Returns true if the user subscribes to the given group and the group is
|
||||||
* visible to the given contact.
|
* visible to the given contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: subscription read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
boolean containsVisibleGroup(T txn, ContactId c, GroupId g)
|
boolean containsVisibleGroup(T txn, ContactId c, GroupId g)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -226,7 +217,7 @@ interface Database<T> {
|
|||||||
* Returns true if the database contains the given message and the message
|
* Returns true if the database contains the given message and the message
|
||||||
* is visible to the given contact.
|
* is visible to the given contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message read, subscription read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
boolean containsVisibleMessage(T txn, ContactId c, MessageId m)
|
boolean containsVisibleMessage(T txn, ContactId c, MessageId m)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -234,7 +225,7 @@ interface Database<T> {
|
|||||||
/**
|
/**
|
||||||
* Returns the number of messages offered by the given contact.
|
* Returns the number of messages offered by the given contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
int countOfferedMessages(T txn, ContactId c) throws DbException;
|
int countOfferedMessages(T txn, ContactId c) throws DbException;
|
||||||
|
|
||||||
@@ -242,49 +233,49 @@ interface Database<T> {
|
|||||||
* Returns the status of all groups to which the user subscribes or can
|
* Returns the status of all groups to which the user subscribes or can
|
||||||
* subscribe, excluding inbox groups.
|
* subscribe, excluding inbox groups.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: subscription read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Collection<GroupStatus> getAvailableGroups(T txn) throws DbException;
|
Collection<GroupStatus> getAvailableGroups(T txn) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the configuration for the given transport.
|
* Returns the configuration for the given transport.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: transport read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
TransportConfig getConfig(T txn, TransportId t) throws DbException;
|
TransportConfig getConfig(T txn, TransportId t) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the contact with the given ID.
|
* Returns the contact with the given ID.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: contact read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Contact getContact(T txn, ContactId c) throws DbException;
|
Contact getContact(T txn, ContactId c) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the IDs of all contacts.
|
* Returns the IDs of all contacts.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: contact read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Collection<ContactId> getContactIds(T txn) throws DbException;
|
Collection<ContactId> getContactIds(T txn) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all contacts.
|
* Returns all contacts.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: contact read, window read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Collection<Contact> getContacts(T txn) throws DbException;
|
Collection<Contact> getContacts(T txn) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all contacts associated with the given local pseudonym.
|
* Returns all contacts associated with the given local pseudonym.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: contact read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Collection<ContactId> getContacts(T txn, AuthorId a) throws DbException;
|
Collection<ContactId> getContacts(T txn, AuthorId a) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all endpoints.
|
* Returns all endpoints.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: window read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Collection<Endpoint> getEndpoints(T txn) throws DbException;
|
Collection<Endpoint> getEndpoints(T txn) throws DbException;
|
||||||
|
|
||||||
@@ -298,14 +289,14 @@ interface Database<T> {
|
|||||||
/**
|
/**
|
||||||
* Returns the group with the given ID, if the user subscribes to it.
|
* Returns the group with the given ID, if the user subscribes to it.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: subscription read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Group getGroup(T txn, GroupId g) throws DbException;
|
Group getGroup(T txn, GroupId g) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all groups to which the user subscribes.
|
* Returns all groups to which the user subscribes.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: subscription read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Collection<Group> getGroups(T txn) throws DbException;
|
Collection<Group> getGroups(T txn) throws DbException;
|
||||||
|
|
||||||
@@ -313,7 +304,7 @@ interface Database<T> {
|
|||||||
* Returns the ID of the inbox group for the given contact, or null if no
|
* Returns the ID of the inbox group for the given contact, or null if no
|
||||||
* inbox group has been set.
|
* inbox group has been set.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: contact read, subscription read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
GroupId getInboxGroupId(T txn, ContactId c) throws DbException;
|
GroupId getInboxGroupId(T txn, ContactId c) throws DbException;
|
||||||
|
|
||||||
@@ -321,7 +312,7 @@ interface Database<T> {
|
|||||||
* Returns the headers of all messages in the inbox group for the given
|
* Returns the headers of all messages in the inbox group for the given
|
||||||
* contact, or null if no inbox group has been set.
|
* contact, or null if no inbox group has been set.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: contact read, identity read, message read, subscription read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Collection<MessageHeader> getInboxMessageHeaders(T txn, ContactId c)
|
Collection<MessageHeader> getInboxMessageHeaders(T txn, ContactId c)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -329,21 +320,21 @@ interface Database<T> {
|
|||||||
/**
|
/**
|
||||||
* Returns the local pseudonym with the given ID.
|
* Returns the local pseudonym with the given ID.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: identity read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
LocalAuthor getLocalAuthor(T txn, AuthorId a) throws DbException;
|
LocalAuthor getLocalAuthor(T txn, AuthorId a) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all local pseudonyms.
|
* Returns all local pseudonyms.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: identity read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Collection<LocalAuthor> getLocalAuthors(T txn) throws DbException;
|
Collection<LocalAuthor> getLocalAuthors(T txn) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the local transport properties for all transports.
|
* Returns the local transport properties for all transports.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: transport read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Map<TransportId, TransportProperties> getLocalProperties(T txn)
|
Map<TransportId, TransportProperties> getLocalProperties(T txn)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -351,7 +342,7 @@ interface Database<T> {
|
|||||||
/**
|
/**
|
||||||
* Returns the local transport properties for the given transport.
|
* Returns the local transport properties for the given transport.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: transport read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
TransportProperties getLocalProperties(T txn, TransportId t)
|
TransportProperties getLocalProperties(T txn, TransportId t)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -359,14 +350,14 @@ interface Database<T> {
|
|||||||
/**
|
/**
|
||||||
* Returns the body of the message identified by the given ID.
|
* Returns the body of the message identified by the given ID.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
byte[] getMessageBody(T txn, MessageId m) throws DbException;
|
byte[] getMessageBody(T txn, MessageId m) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the headers of all messages in the given group.
|
* Returns the headers of all messages in the given group.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Collection<MessageHeader> getMessageHeaders(T txn, GroupId g)
|
Collection<MessageHeader> getMessageHeaders(T txn, GroupId g)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -375,7 +366,7 @@ interface Database<T> {
|
|||||||
* Returns the IDs of some messages received from the given contact that
|
* Returns the IDs of some messages received from the given contact that
|
||||||
* need to be acknowledged, up to the given number of messages.
|
* need to be acknowledged, up to the given number of messages.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Collection<MessageId> getMessagesToAck(T txn, ContactId c, int maxMessages)
|
Collection<MessageId> getMessagesToAck(T txn, ContactId c, int maxMessages)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -384,7 +375,7 @@ interface Database<T> {
|
|||||||
* Returns the IDs of some messages that are eligible to be offered to the
|
* Returns the IDs of some messages that are eligible to be offered to the
|
||||||
* given contact, up to the given number of messages.
|
* given contact, up to the given number of messages.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message read, subscription read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Collection<MessageId> getMessagesToOffer(T txn, ContactId c,
|
Collection<MessageId> getMessagesToOffer(T txn, ContactId c,
|
||||||
int maxMessages) throws DbException;
|
int maxMessages) throws DbException;
|
||||||
@@ -393,7 +384,7 @@ interface Database<T> {
|
|||||||
* Returns the IDs of some messages that are eligible to be sent to the
|
* Returns the IDs of some messages that are eligible to be sent to the
|
||||||
* given contact, up to the given total length.
|
* given contact, up to the given total length.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message read, subscription read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Collection<MessageId> getMessagesToSend(T txn, ContactId c, int maxLength)
|
Collection<MessageId> getMessagesToSend(T txn, ContactId c, int maxLength)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -402,7 +393,7 @@ interface Database<T> {
|
|||||||
* Returns the IDs of some messages that are eligible to be requested from
|
* Returns the IDs of some messages that are eligible to be requested from
|
||||||
* the given contact, up to the given number of messages.
|
* the given contact, up to the given number of messages.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Collection<MessageId> getMessagesToRequest(T txn, ContactId c,
|
Collection<MessageId> getMessagesToRequest(T txn, ContactId c,
|
||||||
int maxMessages) throws DbException;
|
int maxMessages) throws DbException;
|
||||||
@@ -411,7 +402,7 @@ interface Database<T> {
|
|||||||
* Returns the IDs of the oldest messages in the database, with a total
|
* Returns the IDs of the oldest messages in the database, with a total
|
||||||
* size less than or equal to the given size.
|
* size less than or equal to the given size.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Collection<MessageId> getOldMessages(T txn, int size) throws DbException;
|
Collection<MessageId> getOldMessages(T txn, int size) throws DbException;
|
||||||
|
|
||||||
@@ -420,28 +411,28 @@ interface Database<T> {
|
|||||||
* has no parent, or the parent is absent from the database, or the parent
|
* has no parent, or the parent is absent from the database, or the parent
|
||||||
* belongs to a different group.
|
* belongs to a different group.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
MessageId getParent(T txn, MessageId m) throws DbException;
|
MessageId getParent(T txn, MessageId m) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the message identified by the given ID, in serialised form.
|
* Returns the message identified by the given ID, in serialised form.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
byte[] getRawMessage(T txn, MessageId m) throws DbException;
|
byte[] getRawMessage(T txn, MessageId m) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the given message is marked as read.
|
* Returns true if the given message is marked as read.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
boolean getReadFlag(T txn, MessageId m) throws DbException;
|
boolean getReadFlag(T txn, MessageId m) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all remote properties for the given transport.
|
* Returns all remote properties for the given transport.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: transport read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Map<ContactId, TransportProperties> getRemoteProperties(T txn,
|
Map<ContactId, TransportProperties> getRemoteProperties(T txn,
|
||||||
TransportId t) throws DbException;
|
TransportId t) throws DbException;
|
||||||
@@ -451,7 +442,7 @@ interface Database<T> {
|
|||||||
* given contact and have been requested by the contact, up to the given
|
* given contact and have been requested by the contact, up to the given
|
||||||
* total length.
|
* total length.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message read, subscription read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Collection<MessageId> getRequestedMessagesToSend(T txn, ContactId c,
|
Collection<MessageId> getRequestedMessagesToSend(T txn, ContactId c,
|
||||||
int maxLength) throws DbException;
|
int maxLength) throws DbException;
|
||||||
@@ -459,7 +450,7 @@ interface Database<T> {
|
|||||||
/**
|
/**
|
||||||
* Returns a retention ack for the given contact, or null if no ack is due.
|
* Returns a retention ack for the given contact, or null if no ack is due.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: retention write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
RetentionAck getRetentionAck(T txn, ContactId c) throws DbException;
|
RetentionAck getRetentionAck(T txn, ContactId c) throws DbException;
|
||||||
|
|
||||||
@@ -467,7 +458,7 @@ interface Database<T> {
|
|||||||
* Returns a retention update for the given contact and updates its expiry
|
* Returns a retention update for the given contact and updates its expiry
|
||||||
* time using the given latency, or returns null if no update is due.
|
* time using the given latency, or returns null if no update is due.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message read, retention write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
RetentionUpdate getRetentionUpdate(T txn, ContactId c, long maxLatency)
|
RetentionUpdate getRetentionUpdate(T txn, ContactId c, long maxLatency)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -475,21 +466,21 @@ interface Database<T> {
|
|||||||
/**
|
/**
|
||||||
* Returns all temporary secrets.
|
* Returns all temporary secrets.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: window read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Collection<TemporarySecret> getSecrets(T txn) throws DbException;
|
Collection<TemporarySecret> getSecrets(T txn) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all settings.
|
* Returns all settings.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: setting read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Settings getSettings(T txn) throws DbException;
|
Settings getSettings(T txn) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all contacts who subscribe to the given group.
|
* Returns all contacts who subscribe to the given group.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: subscription read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Collection<Contact> getSubscribers(T txn, GroupId g) throws DbException;
|
Collection<Contact> getSubscribers(T txn, GroupId g) throws DbException;
|
||||||
|
|
||||||
@@ -497,7 +488,7 @@ interface Database<T> {
|
|||||||
* Returns a subscription ack for the given contact, or null if no ack is
|
* Returns a subscription ack for the given contact, or null if no ack is
|
||||||
* due.
|
* due.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: subscription write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
SubscriptionAck getSubscriptionAck(T txn, ContactId c) throws DbException;
|
SubscriptionAck getSubscriptionAck(T txn, ContactId c) throws DbException;
|
||||||
|
|
||||||
@@ -505,7 +496,7 @@ interface Database<T> {
|
|||||||
* Returns a subscription update for the given contact and updates its
|
* Returns a subscription update for the given contact and updates its
|
||||||
* expiry time using the given latency, or returns null if no update is due.
|
* expiry time using the given latency, or returns null if no update is due.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: subscription write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
SubscriptionUpdate getSubscriptionUpdate(T txn, ContactId c,
|
SubscriptionUpdate getSubscriptionUpdate(T txn, ContactId c,
|
||||||
long maxLatency) throws DbException;
|
long maxLatency) throws DbException;
|
||||||
@@ -514,7 +505,7 @@ interface Database<T> {
|
|||||||
* Returns a collection of transport acks for the given contact, or null if
|
* Returns a collection of transport acks for the given contact, or null if
|
||||||
* no acks are due.
|
* no acks are due.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: transport write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
Collection<TransportAck> getTransportAcks(T txn, ContactId c)
|
Collection<TransportAck> getTransportAcks(T txn, ContactId c)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -522,7 +513,7 @@ interface Database<T> {
|
|||||||
/**
|
/**
|
||||||
* Returns the maximum latencies of all local transports.
|
* Returns the maximum latencies of all local transports.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: transport read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Map<TransportId, Long> getTransportLatencies(T txn) throws DbException;
|
Map<TransportId, Long> getTransportLatencies(T txn) throws DbException;
|
||||||
|
|
||||||
@@ -531,7 +522,7 @@ interface Database<T> {
|
|||||||
* updates their expiry times using the given latency, or returns null if
|
* updates their expiry times using the given latency, or returns null if
|
||||||
* no updates are due.
|
* no updates are due.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: transport write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
Collection<TransportUpdate> getTransportUpdates(T txn, ContactId c,
|
Collection<TransportUpdate> getTransportUpdates(T txn, ContactId c,
|
||||||
long maxLatency) throws DbException;
|
long maxLatency) throws DbException;
|
||||||
@@ -539,14 +530,14 @@ interface Database<T> {
|
|||||||
/**
|
/**
|
||||||
* Returns the number of unread messages in each subscribed group.
|
* Returns the number of unread messages in each subscribed group.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Map<GroupId, Integer> getUnreadMessageCounts(T txn) throws DbException;
|
Map<GroupId, Integer> getUnreadMessageCounts(T txn) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the IDs of all contacts to which the given group is visible.
|
* Returns the IDs of all contacts to which the given group is visible.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: subscription read.
|
* Locking: read.
|
||||||
*/
|
*/
|
||||||
Collection<ContactId> getVisibility(T txn, GroupId g) throws DbException;
|
Collection<ContactId> getVisibility(T txn, GroupId g) throws DbException;
|
||||||
|
|
||||||
@@ -555,7 +546,7 @@ interface Database<T> {
|
|||||||
* in the given rotation period and returns the old value, or -1 if the
|
* in the given rotation period and returns the old value, or -1 if the
|
||||||
* counter does not exist.
|
* counter does not exist.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: window write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
long incrementConnectionCounter(T txn, ContactId c, TransportId t,
|
long incrementConnectionCounter(T txn, ContactId c, TransportId t,
|
||||||
long period) throws DbException;
|
long period) throws DbException;
|
||||||
@@ -564,7 +555,7 @@ interface Database<T> {
|
|||||||
* Increments the retention time versions for all contacts to indicate that
|
* Increments the retention time versions for all contacts to indicate that
|
||||||
* the database's retention time has changed and updates should be sent.
|
* the database's retention time has changed and updates should be sent.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: retention write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void incrementRetentionVersions(T txn) throws DbException;
|
void incrementRetentionVersions(T txn) throws DbException;
|
||||||
|
|
||||||
@@ -572,7 +563,7 @@ interface Database<T> {
|
|||||||
* Marks the given messages as not needing to be acknowledged to the
|
* Marks the given messages as not needing to be acknowledged to the
|
||||||
* given contact.
|
* given contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void lowerAckFlag(T txn, ContactId c, Collection<MessageId> acked)
|
void lowerAckFlag(T txn, ContactId c, Collection<MessageId> acked)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -581,7 +572,7 @@ interface Database<T> {
|
|||||||
* Marks the given messages as not having been requested by the given
|
* Marks the given messages as not having been requested by the given
|
||||||
* contact.
|
* contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void lowerRequestedFlag(T txn, ContactId c, Collection<MessageId> requested)
|
void lowerRequestedFlag(T txn, ContactId c, Collection<MessageId> requested)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -590,7 +581,7 @@ interface Database<T> {
|
|||||||
* Merges the given configuration with the existing configuration for the
|
* Merges the given configuration with the existing configuration for the
|
||||||
* given transport.
|
* given transport.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: transport write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void mergeConfig(T txn, TransportId t, TransportConfig config)
|
void mergeConfig(T txn, TransportId t, TransportConfig config)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -599,7 +590,7 @@ interface Database<T> {
|
|||||||
* Merges the given properties with the existing local properties for the
|
* Merges the given properties with the existing local properties for the
|
||||||
* given transport.
|
* given transport.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: transport write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void mergeLocalProperties(T txn, TransportId t, TransportProperties p)
|
void mergeLocalProperties(T txn, TransportId t, TransportProperties p)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -607,36 +598,35 @@ interface Database<T> {
|
|||||||
/**
|
/**
|
||||||
* Merges the given settings with the existing settings.
|
* Merges the given settings with the existing settings.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: setting write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void mergeSettings(T txn, Settings s) throws DbException;
|
void mergeSettings(T txn, Settings s) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks a message as needing to be acknowledged to the given contact.
|
* Marks a message as needing to be acknowledged to the given contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void raiseAckFlag(T txn, ContactId c, MessageId m) throws DbException;
|
void raiseAckFlag(T txn, ContactId c, MessageId m) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks a message as having been requested by the given contact.
|
* Marks a message as having been requested by the given contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void raiseRequestedFlag(T txn, ContactId c, MessageId m) throws DbException;
|
void raiseRequestedFlag(T txn, ContactId c, MessageId m) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks a message as having been seen by the given contact.
|
* Marks a message as having been seen by the given contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void raiseSeenFlag(T txn, ContactId c, MessageId m) throws DbException;
|
void raiseSeenFlag(T txn, ContactId c, MessageId m) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a contact from the database.
|
* Removes a contact from the database.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: contact write, message write, retention write,
|
* Locking: write.
|
||||||
* subscription write, transport write, window write.
|
|
||||||
*/
|
*/
|
||||||
void removeContact(T txn, ContactId c) throws DbException;
|
void removeContact(T txn, ContactId c) throws DbException;
|
||||||
|
|
||||||
@@ -644,7 +634,7 @@ interface Database<T> {
|
|||||||
* Unsubscribes from a group. Any messages belonging to the group are
|
* Unsubscribes from a group. Any messages belonging to the group are
|
||||||
* deleted from the database.
|
* deleted from the database.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message write, subscription write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void removeGroup(T txn, GroupId g) throws DbException;
|
void removeGroup(T txn, GroupId g) throws DbException;
|
||||||
|
|
||||||
@@ -652,15 +642,14 @@ interface Database<T> {
|
|||||||
* Removes a local pseudonym (and all associated contacts) from the
|
* Removes a local pseudonym (and all associated contacts) from the
|
||||||
* database.
|
* database.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: contact write, identity write, message write, retention write,
|
* Locking: write.
|
||||||
* subscription write, transport write, window write.
|
|
||||||
*/
|
*/
|
||||||
void removeLocalAuthor(T txn, AuthorId a) throws DbException;
|
void removeLocalAuthor(T txn, AuthorId a) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a message (and all associated state) from the database.
|
* Removes a message (and all associated state) from the database.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void removeMessage(T txn, MessageId m) throws DbException;
|
void removeMessage(T txn, MessageId m) throws DbException;
|
||||||
|
|
||||||
@@ -668,7 +657,7 @@ interface Database<T> {
|
|||||||
* Removes an offered message that was offered by the given contact, or
|
* Removes an offered message that was offered by the given contact, or
|
||||||
* returns false if there is no such message.
|
* returns false if there is no such message.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
boolean removeOfferedMessage(T txn, ContactId c, MessageId m)
|
boolean removeOfferedMessage(T txn, ContactId c, MessageId m)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -677,7 +666,7 @@ interface Database<T> {
|
|||||||
* Removes the given offered messages that were offered by the given
|
* Removes the given offered messages that were offered by the given
|
||||||
* contact.
|
* contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void removeOfferedMessages(T txn, ContactId c,
|
void removeOfferedMessages(T txn, ContactId c,
|
||||||
Collection<MessageId> requested) throws DbException;
|
Collection<MessageId> requested) throws DbException;
|
||||||
@@ -685,14 +674,14 @@ interface Database<T> {
|
|||||||
/**
|
/**
|
||||||
* Removes a transport (and all associated state) from the database.
|
* Removes a transport (and all associated state) from the database.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: transport write, window write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void removeTransport(T txn, TransportId t) throws DbException;
|
void removeTransport(T txn, TransportId t) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a group invisible to the given contact.
|
* Makes a group invisible to the given contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: subscription write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void removeVisibility(T txn, ContactId c, GroupId g) throws DbException;
|
void removeVisibility(T txn, ContactId c, GroupId g) throws DbException;
|
||||||
|
|
||||||
@@ -700,7 +689,7 @@ interface Database<T> {
|
|||||||
* Resets the transmission count and expiry time of the given message with
|
* Resets the transmission count and expiry time of the given message with
|
||||||
* respect to the given contact.
|
* respect to the given contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void resetExpiryTime(T txn, ContactId c, MessageId m) throws DbException;
|
void resetExpiryTime(T txn, ContactId c, MessageId m) throws DbException;
|
||||||
|
|
||||||
@@ -708,7 +697,7 @@ interface Database<T> {
|
|||||||
* Sets the connection reordering window for the given endpoint in the
|
* Sets the connection reordering window for the given endpoint in the
|
||||||
* given rotation period.
|
* given rotation period.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: window write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void setConnectionWindow(T txn, ContactId c, TransportId t, long period,
|
void setConnectionWindow(T txn, ContactId c, TransportId t, long period,
|
||||||
long centre, byte[] bitmap) throws DbException;
|
long centre, byte[] bitmap) throws DbException;
|
||||||
@@ -718,7 +707,7 @@ interface Database<T> {
|
|||||||
* true, unless an update with an equal or higher version number has
|
* true, unless an update with an equal or higher version number has
|
||||||
* already been received from the contact.
|
* already been received from the contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message write, subscription write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
boolean setGroups(T txn, ContactId c, Collection<Group> groups,
|
boolean setGroups(T txn, ContactId c, Collection<Group> groups,
|
||||||
long version) throws DbException;
|
long version) throws DbException;
|
||||||
@@ -727,14 +716,14 @@ interface Database<T> {
|
|||||||
* Makes a group visible to the given contact, adds it to the contact's
|
* Makes a group visible to the given contact, adds it to the contact's
|
||||||
* subscriptions, and sets it as the inbox group for the contact.
|
* subscriptions, and sets it as the inbox group for the contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: subscription write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
public void setInboxGroup(T txn, ContactId c, Group g) throws DbException;
|
public void setInboxGroup(T txn, ContactId c, Group g) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks a message as read or unread.
|
* Marks a message as read or unread.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void setReadFlag(T txn, MessageId m, boolean read) throws DbException;
|
void setReadFlag(T txn, MessageId m, boolean read) throws DbException;
|
||||||
|
|
||||||
@@ -742,7 +731,7 @@ interface Database<T> {
|
|||||||
* Sets the remote transport properties for the given contact, replacing
|
* Sets the remote transport properties for the given contact, replacing
|
||||||
* any existing properties.
|
* any existing properties.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: transport write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void setRemoteProperties(T txn, ContactId c,
|
void setRemoteProperties(T txn, ContactId c,
|
||||||
Map<TransportId, TransportProperties> p) throws DbException;
|
Map<TransportId, TransportProperties> p) throws DbException;
|
||||||
@@ -753,7 +742,7 @@ interface Database<T> {
|
|||||||
* unless an update with an equal or higher version number has already been
|
* unless an update with an equal or higher version number has already been
|
||||||
* received from the contact.
|
* received from the contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: transport write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
boolean setRemoteProperties(T txn, ContactId c, TransportId t,
|
boolean setRemoteProperties(T txn, ContactId c, TransportId t,
|
||||||
TransportProperties p, long version) throws DbException;
|
TransportProperties p, long version) throws DbException;
|
||||||
@@ -763,7 +752,7 @@ interface Database<T> {
|
|||||||
* true, unless an update with an equal or higher version number has
|
* true, unless an update with an equal or higher version number has
|
||||||
* already been received from the contact.
|
* already been received from the contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: retention write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
boolean setRetentionTime(T txn, ContactId c, long retention, long version)
|
boolean setRetentionTime(T txn, ContactId c, long retention, long version)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -772,7 +761,7 @@ interface Database<T> {
|
|||||||
* Records a retention ack from the given contact for the given version,
|
* Records a retention ack from the given contact for the given version,
|
||||||
* unless the contact has already acked an equal or higher version.
|
* unless the contact has already acked an equal or higher version.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: retention write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void setRetentionUpdateAcked(T txn, ContactId c, long version)
|
void setRetentionUpdateAcked(T txn, ContactId c, long version)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -781,7 +770,7 @@ interface Database<T> {
|
|||||||
* Records a subscription ack from the given contact for the given version,
|
* Records a subscription ack from the given contact for the given version,
|
||||||
* unless the contact has already acked an equal or higher version.
|
* unless the contact has already acked an equal or higher version.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: subscription write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void setSubscriptionUpdateAcked(T txn, ContactId c, long version)
|
void setSubscriptionUpdateAcked(T txn, ContactId c, long version)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
@@ -790,7 +779,7 @@ interface Database<T> {
|
|||||||
* Records a transport ack from the give contact for the given version,
|
* Records a transport ack from the give contact for the given version,
|
||||||
* unless the contact has already acked an equal or higher version.
|
* unless the contact has already acked an equal or higher version.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: transport write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void setTransportUpdateAcked(T txn, ContactId c, TransportId t,
|
void setTransportUpdateAcked(T txn, ContactId c, TransportId t,
|
||||||
long version) throws DbException;
|
long version) throws DbException;
|
||||||
@@ -798,7 +787,7 @@ interface Database<T> {
|
|||||||
/**
|
/**
|
||||||
* Makes a group visible or invisible to future contacts by default.
|
* Makes a group visible or invisible to future contacts by default.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: subscription write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void setVisibleToAll(T txn, GroupId g, boolean all) throws DbException;
|
void setVisibleToAll(T txn, GroupId g, boolean all) throws DbException;
|
||||||
|
|
||||||
@@ -807,7 +796,7 @@ interface Database<T> {
|
|||||||
* with respect to the given contact, using the latency of the transport
|
* with respect to the given contact, using the latency of the transport
|
||||||
* over which it was sent.
|
* over which it was sent.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: message write.
|
* Locking: write.
|
||||||
*/
|
*/
|
||||||
void updateExpiryTime(T txn, ContactId c, MessageId m, long maxLatency)
|
void updateExpiryTime(T txn, ContactId c, MessageId m, long maxLatency)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -71,8 +71,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
+ " value VARCHAR NOT NULL,"
|
+ " value VARCHAR NOT NULL,"
|
||||||
+ " PRIMARY KEY (key))";
|
+ " PRIMARY KEY (key))";
|
||||||
|
|
||||||
// Locking: identity
|
|
||||||
// Dependents: contact, message, retention, subscription, transport, window
|
|
||||||
private static final String CREATE_LOCAL_AUTHORS =
|
private static final String CREATE_LOCAL_AUTHORS =
|
||||||
"CREATE TABLE localAuthors"
|
"CREATE TABLE localAuthors"
|
||||||
+ " (authorId HASH NOT NULL,"
|
+ " (authorId HASH NOT NULL,"
|
||||||
@@ -82,8 +80,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
+ " created BIGINT NOT NULL,"
|
+ " created BIGINT NOT NULL,"
|
||||||
+ " PRIMARY KEY (authorId))";
|
+ " PRIMARY KEY (authorId))";
|
||||||
|
|
||||||
// Locking: contact
|
|
||||||
// Dependents: message, retention, subscription, transport, window
|
|
||||||
private static final String CREATE_CONTACTS =
|
private static final String CREATE_CONTACTS =
|
||||||
"CREATE TABLE contacts"
|
"CREATE TABLE contacts"
|
||||||
+ " (contactId COUNTER,"
|
+ " (contactId COUNTER,"
|
||||||
@@ -97,8 +93,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
+ " REFERENCES localAuthors (authorId)"
|
+ " REFERENCES localAuthors (authorId)"
|
||||||
+ " ON DELETE CASCADE)";
|
+ " ON DELETE CASCADE)";
|
||||||
|
|
||||||
// Locking: subscription
|
|
||||||
// Dependents: message
|
|
||||||
private static final String CREATE_GROUPS =
|
private static final String CREATE_GROUPS =
|
||||||
"CREATE TABLE groups"
|
"CREATE TABLE groups"
|
||||||
+ " (groupId HASH NOT NULL,"
|
+ " (groupId HASH NOT NULL,"
|
||||||
@@ -107,7 +101,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
+ " visibleToAll BOOLEAN NOT NULL,"
|
+ " visibleToAll BOOLEAN NOT NULL,"
|
||||||
+ " PRIMARY KEY (groupId))";
|
+ " PRIMARY KEY (groupId))";
|
||||||
|
|
||||||
// Locking: subscription
|
|
||||||
private static final String CREATE_GROUP_VISIBILITIES =
|
private static final String CREATE_GROUP_VISIBILITIES =
|
||||||
"CREATE TABLE groupVisibilities"
|
"CREATE TABLE groupVisibilities"
|
||||||
+ " (contactId INT NOT NULL,"
|
+ " (contactId INT NOT NULL,"
|
||||||
@@ -121,7 +114,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
+ " REFERENCES groups (groupId)"
|
+ " REFERENCES groups (groupId)"
|
||||||
+ " ON DELETE CASCADE)";
|
+ " ON DELETE CASCADE)";
|
||||||
|
|
||||||
// Locking: subscription
|
|
||||||
private static final String CREATE_CONTACT_GROUPS =
|
private static final String CREATE_CONTACT_GROUPS =
|
||||||
"CREATE TABLE contactGroups"
|
"CREATE TABLE contactGroups"
|
||||||
+ " (contactId INT NOT NULL,"
|
+ " (contactId INT NOT NULL,"
|
||||||
@@ -133,7 +125,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
+ " REFERENCES contacts (contactId)"
|
+ " REFERENCES contacts (contactId)"
|
||||||
+ " ON DELETE CASCADE)";
|
+ " ON DELETE CASCADE)";
|
||||||
|
|
||||||
// Locking: subscription
|
|
||||||
private static final String CREATE_GROUP_VERSIONS =
|
private static final String CREATE_GROUP_VERSIONS =
|
||||||
"CREATE TABLE groupVersions"
|
"CREATE TABLE groupVersions"
|
||||||
+ " (contactId INT NOT NULL,"
|
+ " (contactId INT NOT NULL,"
|
||||||
@@ -148,7 +139,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
+ " REFERENCES contacts (contactId)"
|
+ " REFERENCES contacts (contactId)"
|
||||||
+ " ON DELETE CASCADE)";
|
+ " ON DELETE CASCADE)";
|
||||||
|
|
||||||
// Locking: message
|
|
||||||
private static final String CREATE_MESSAGES =
|
private static final String CREATE_MESSAGES =
|
||||||
"CREATE TABLE messages"
|
"CREATE TABLE messages"
|
||||||
+ " (messageId HASH NOT NULL,"
|
+ " (messageId HASH NOT NULL,"
|
||||||
@@ -182,7 +172,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
+ " REFERENCES contacts (contactId)"
|
+ " REFERENCES contacts (contactId)"
|
||||||
+ " ON DELETE CASCADE)";
|
+ " ON DELETE CASCADE)";
|
||||||
|
|
||||||
// Locking: message
|
|
||||||
private static final String CREATE_STATUSES =
|
private static final String CREATE_STATUSES =
|
||||||
"CREATE TABLE statuses"
|
"CREATE TABLE statuses"
|
||||||
+ " (messageId HASH NOT NULL,"
|
+ " (messageId HASH NOT NULL,"
|
||||||
@@ -206,7 +195,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
private static final String INDEX_STATUSES_BY_CONTACT =
|
private static final String INDEX_STATUSES_BY_CONTACT =
|
||||||
"CREATE INDEX statusesByContact ON statuses (contactId)";
|
"CREATE INDEX statusesByContact ON statuses (contactId)";
|
||||||
|
|
||||||
// Locking: retention
|
|
||||||
private static final String CREATE_RETENTION_VERSIONS =
|
private static final String CREATE_RETENTION_VERSIONS =
|
||||||
"CREATE TABLE retentionVersions"
|
"CREATE TABLE retentionVersions"
|
||||||
+ " (contactId INT NOT NULL,"
|
+ " (contactId INT NOT NULL,"
|
||||||
@@ -222,15 +210,12 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
+ " REFERENCES contacts (contactId)"
|
+ " REFERENCES contacts (contactId)"
|
||||||
+ " ON DELETE CASCADE)";
|
+ " ON DELETE CASCADE)";
|
||||||
|
|
||||||
// Locking: transport
|
|
||||||
// Dependents: window
|
|
||||||
private static final String CREATE_TRANSPORTS =
|
private static final String CREATE_TRANSPORTS =
|
||||||
"CREATE TABLE transports"
|
"CREATE TABLE transports"
|
||||||
+ " (transportId VARCHAR NOT NULL,"
|
+ " (transportId VARCHAR NOT NULL,"
|
||||||
+ " maxLatency BIGINT NOT NULL,"
|
+ " maxLatency BIGINT NOT NULL,"
|
||||||
+ " PRIMARY KEY (transportId))";
|
+ " PRIMARY KEY (transportId))";
|
||||||
|
|
||||||
// Locking: transport
|
|
||||||
private static final String CREATE_TRANSPORT_CONFIGS =
|
private static final String CREATE_TRANSPORT_CONFIGS =
|
||||||
"CREATE TABLE transportConfigs"
|
"CREATE TABLE transportConfigs"
|
||||||
+ " (transportId VARCHAR NOT NULL,"
|
+ " (transportId VARCHAR NOT NULL,"
|
||||||
@@ -241,7 +226,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
+ " REFERENCES transports (transportId)"
|
+ " REFERENCES transports (transportId)"
|
||||||
+ " ON DELETE CASCADE)";
|
+ " ON DELETE CASCADE)";
|
||||||
|
|
||||||
// Locking: transport
|
|
||||||
private static final String CREATE_TRANSPORT_PROPS =
|
private static final String CREATE_TRANSPORT_PROPS =
|
||||||
"CREATE TABLE transportProperties"
|
"CREATE TABLE transportProperties"
|
||||||
+ " (transportId VARCHAR NOT NULL,"
|
+ " (transportId VARCHAR NOT NULL,"
|
||||||
@@ -252,7 +236,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
+ " REFERENCES transports (transportId)"
|
+ " REFERENCES transports (transportId)"
|
||||||
+ " ON DELETE CASCADE)";
|
+ " ON DELETE CASCADE)";
|
||||||
|
|
||||||
// Locking: transport
|
|
||||||
private static final String CREATE_TRANSPORT_VERSIONS =
|
private static final String CREATE_TRANSPORT_VERSIONS =
|
||||||
"CREATE TABLE transportVersions"
|
"CREATE TABLE transportVersions"
|
||||||
+ " (contactId INT NOT NULL,"
|
+ " (contactId INT NOT NULL,"
|
||||||
@@ -269,7 +252,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
+ " REFERENCES transports (transportId)"
|
+ " REFERENCES transports (transportId)"
|
||||||
+ " ON DELETE CASCADE)";
|
+ " ON DELETE CASCADE)";
|
||||||
|
|
||||||
// Locking: transport
|
|
||||||
private static final String CREATE_CONTACT_TRANSPORT_PROPS =
|
private static final String CREATE_CONTACT_TRANSPORT_PROPS =
|
||||||
"CREATE TABLE contactTransportProperties"
|
"CREATE TABLE contactTransportProperties"
|
||||||
+ " (contactId INT NOT NULL,"
|
+ " (contactId INT NOT NULL,"
|
||||||
@@ -281,7 +263,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
+ " REFERENCES contacts (contactId)"
|
+ " REFERENCES contacts (contactId)"
|
||||||
+ " ON DELETE CASCADE)";
|
+ " ON DELETE CASCADE)";
|
||||||
|
|
||||||
// Locking: transport
|
|
||||||
private static final String CREATE_CONTACT_TRANSPORT_VERSIONS =
|
private static final String CREATE_CONTACT_TRANSPORT_VERSIONS =
|
||||||
"CREATE TABLE contactTransportVersions"
|
"CREATE TABLE contactTransportVersions"
|
||||||
+ " (contactId INT NOT NULL,"
|
+ " (contactId INT NOT NULL,"
|
||||||
@@ -293,7 +274,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
+ " REFERENCES contacts (contactId)"
|
+ " REFERENCES contacts (contactId)"
|
||||||
+ " ON DELETE CASCADE)";
|
+ " ON DELETE CASCADE)";
|
||||||
|
|
||||||
// Locking: window
|
|
||||||
private static final String CREATE_ENDPOINTS =
|
private static final String CREATE_ENDPOINTS =
|
||||||
"CREATE TABLE endpoints"
|
"CREATE TABLE endpoints"
|
||||||
+ " (contactId INT NOT NULL,"
|
+ " (contactId INT NOT NULL,"
|
||||||
@@ -308,7 +288,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
+ " REFERENCES transports (transportId)"
|
+ " REFERENCES transports (transportId)"
|
||||||
+ " ON DELETE CASCADE)";
|
+ " ON DELETE CASCADE)";
|
||||||
|
|
||||||
// Locking: window
|
|
||||||
private static final String CREATE_SECRETS =
|
private static final String CREATE_SECRETS =
|
||||||
"CREATE TABLE secrets"
|
"CREATE TABLE secrets"
|
||||||
+ " (contactId INT NOT NULL,"
|
+ " (contactId INT NOT NULL,"
|
||||||
|
|||||||
Reference in New Issue
Block a user