|
|
|
|
@@ -200,26 +200,15 @@ public interface DatabaseComponent extends TransactionManager {
|
|
|
|
|
throws DbException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns a batch of messages for the given contact, with a total length
|
|
|
|
|
* less than or equal to the given length, for transmission over a
|
|
|
|
|
* transport with the given maximum latency. Returns null if there are no
|
|
|
|
|
* sendable messages that fit in the given length.
|
|
|
|
|
* Returns a batch of messages for the given contact, for transmission over
|
|
|
|
|
* a transport with the given maximum latency. The total length of the
|
|
|
|
|
* messages, including record headers, will be no more than the given
|
|
|
|
|
* capacity. Returns null if there are no sendable messages that would fit
|
|
|
|
|
* in the given capacity.
|
|
|
|
|
*/
|
|
|
|
|
@Nullable
|
|
|
|
|
Collection<Message> generateBatch(Transaction txn, ContactId c,
|
|
|
|
|
int maxLength, long maxLatency) throws DbException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns a batch of messages for the given contact containing the
|
|
|
|
|
* messages with the given IDs, for transmission over a transport with
|
|
|
|
|
* the given maximum latency.
|
|
|
|
|
* <p/>
|
|
|
|
|
* If any of the given messages are not in the database or are not visible
|
|
|
|
|
* to the contact, they are omitted from the batch without throwing an
|
|
|
|
|
* exception.
|
|
|
|
|
*/
|
|
|
|
|
Collection<Message> generateBatch(Transaction txn, ContactId c,
|
|
|
|
|
Collection<MessageId> ids, long maxLatency) throws DbException;
|
|
|
|
|
int capacity, long maxLatency) throws DbException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns an offer for the given contact for transmission over a
|
|
|
|
|
@@ -239,15 +228,16 @@ public interface DatabaseComponent extends TransactionManager {
|
|
|
|
|
throws DbException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns a batch of messages for the given contact, with a total length
|
|
|
|
|
* less than or equal to the given length, for transmission over a
|
|
|
|
|
* transport with the given maximum latency. Only messages that have been
|
|
|
|
|
* requested by the contact are returned. Returns null if there are no
|
|
|
|
|
* sendable messages that fit in the given length.
|
|
|
|
|
* Returns a batch of messages for the given contact, for transmission over
|
|
|
|
|
* a transport with the given maximum latency. Only messages that have been
|
|
|
|
|
* requested by the contact are returned. The total length of the messages,
|
|
|
|
|
* including record headers, will be no more than the given capacity.
|
|
|
|
|
* Returns null if there are no sendable messages that have been requested
|
|
|
|
|
* by the contact and would fit in the given capacity.
|
|
|
|
|
*/
|
|
|
|
|
@Nullable
|
|
|
|
|
Collection<Message> generateRequestedBatch(Transaction txn, ContactId c,
|
|
|
|
|
int maxLength, long maxLatency) throws DbException;
|
|
|
|
|
int capacity, long maxLatency) throws DbException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the contact with the given ID.
|
|
|
|
|
@@ -351,6 +341,30 @@ public interface DatabaseComponent extends TransactionManager {
|
|
|
|
|
Collection<MessageId> getMessageIds(Transaction txn, GroupId g,
|
|
|
|
|
Metadata query) throws DbException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the IDs of some messages received from the given contact that
|
|
|
|
|
* need to be acknowledged, up to the given number of messages.
|
|
|
|
|
* <p/>
|
|
|
|
|
* Read-only.
|
|
|
|
|
*/
|
|
|
|
|
Collection<MessageId> getMessagesToAck(Transaction txn, ContactId c,
|
|
|
|
|
int maxMessages) throws DbException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the IDs of some messages that are eligible to be sent to the
|
|
|
|
|
* given contact over a transport with the given maximum latency. The total
|
|
|
|
|
* length of the messages including record headers will be no more than the
|
|
|
|
|
* given capacity.
|
|
|
|
|
* <p/>
|
|
|
|
|
* Unlike {@link #getUnackedMessagesToSend(Transaction, ContactId)} this
|
|
|
|
|
* method does not return messages that have already been sent unless they
|
|
|
|
|
* are due for retransmission.
|
|
|
|
|
* <p/>
|
|
|
|
|
* Read-only.
|
|
|
|
|
*/
|
|
|
|
|
Collection<MessageId> getMessagesToSend(Transaction txn, ContactId c,
|
|
|
|
|
int capacity, long maxLatency) throws DbException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the IDs of any messages that need to be validated.
|
|
|
|
|
* <p/>
|
|
|
|
|
@@ -467,15 +481,30 @@ public interface DatabaseComponent extends TransactionManager {
|
|
|
|
|
MessageStatus getMessageStatus(Transaction txn, ContactId c, MessageId m)
|
|
|
|
|
throws DbException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the message with the given ID for transmission to the given
|
|
|
|
|
* contact over a transport with the given maximum latency. Returns null
|
|
|
|
|
* if the message is no longer visible to the contact.
|
|
|
|
|
*
|
|
|
|
|
* @param markAsSent True if the message should be marked as sent.
|
|
|
|
|
* If false it can be marked as sent by calling
|
|
|
|
|
* {@link #setMessagesSent(Transaction, ContactId, Collection, long)}.
|
|
|
|
|
*/
|
|
|
|
|
@Nullable
|
|
|
|
|
Message getMessageToSend(Transaction txn, ContactId c, MessageId m,
|
|
|
|
|
long maxLatency, boolean markAsSent) throws DbException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the IDs of all messages that are eligible to be sent to the
|
|
|
|
|
* given contact, together with their raw lengths. This may include
|
|
|
|
|
* messages that have already been sent and are not yet due for
|
|
|
|
|
* retransmission.
|
|
|
|
|
* given contact.
|
|
|
|
|
* <p>
|
|
|
|
|
* Unlike {@link #getMessagesToSend(Transaction, ContactId, int, long)}
|
|
|
|
|
* this method may return messages that have already been sent and are
|
|
|
|
|
* not yet due for retransmission.
|
|
|
|
|
* <p/>
|
|
|
|
|
* Read-only.
|
|
|
|
|
*/
|
|
|
|
|
Map<MessageId, Integer> getUnackedMessagesToSend(Transaction txn,
|
|
|
|
|
Collection<MessageId> getUnackedMessagesToSend(Transaction txn,
|
|
|
|
|
ContactId c) throws DbException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -655,6 +684,13 @@ public interface DatabaseComponent extends TransactionManager {
|
|
|
|
|
void removeTransportKeys(Transaction txn, TransportId t, KeySetId k)
|
|
|
|
|
throws DbException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Records an ack for the given messages as having been sent to the given
|
|
|
|
|
* contact.
|
|
|
|
|
*/
|
|
|
|
|
void setAckSent(Transaction txn, ContactId c, Collection<MessageId> acked)
|
|
|
|
|
throws DbException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the cleanup timer duration for the given message. This does not
|
|
|
|
|
* start the message's cleanup timer.
|
|
|
|
|
@@ -701,6 +737,13 @@ public interface DatabaseComponent extends TransactionManager {
|
|
|
|
|
void setMessageState(Transaction txn, MessageId m, MessageState state)
|
|
|
|
|
throws DbException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Records the given messages as having been sent to the given contact
|
|
|
|
|
* over a transport with the given maximum latency.
|
|
|
|
|
*/
|
|
|
|
|
void setMessagesSent(Transaction txn, ContactId c,
|
|
|
|
|
Collection<MessageId> sent, long maxLatency) throws DbException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds dependencies for a message
|
|
|
|
|
*/
|
|
|
|
|
|