mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 06:09:55 +01:00
Log how long it takes to deliver private messages and attachments.
This commit is contained in:
@@ -53,14 +53,18 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
import javax.annotation.concurrent.Immutable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static java.util.Collections.emptyList;
|
import static java.util.Collections.emptyList;
|
||||||
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.bramble.api.client.ContactGroupConstants.GROUP_KEY_CONTACT_ID;
|
import static org.briarproject.bramble.api.client.ContactGroupConstants.GROUP_KEY_CONTACT_ID;
|
||||||
import static org.briarproject.bramble.api.sync.SyncConstants.MAX_MESSAGE_BODY_LENGTH;
|
import static org.briarproject.bramble.api.sync.SyncConstants.MAX_MESSAGE_BODY_LENGTH;
|
||||||
import static org.briarproject.bramble.util.IoUtils.copyAndClose;
|
import static org.briarproject.bramble.util.IoUtils.copyAndClose;
|
||||||
|
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
||||||
|
import static org.briarproject.bramble.util.LogUtils.now;
|
||||||
import static org.briarproject.briar.api.attachment.MediaConstants.MSG_KEY_CONTENT_TYPE;
|
import static org.briarproject.briar.api.attachment.MediaConstants.MSG_KEY_CONTENT_TYPE;
|
||||||
import static org.briarproject.briar.api.attachment.MediaConstants.MSG_KEY_DESCRIPTOR_LENGTH;
|
import static org.briarproject.briar.api.attachment.MediaConstants.MSG_KEY_DESCRIPTOR_LENGTH;
|
||||||
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.NO_AUTO_DELETE_TIMER;
|
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.NO_AUTO_DELETE_TIMER;
|
||||||
@@ -84,6 +88,9 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
|
|||||||
ConversationClient, OpenDatabaseHook, ContactHook,
|
ConversationClient, OpenDatabaseHook, ContactHook,
|
||||||
ClientVersioningHook, CleanupHook {
|
ClientVersioningHook, CleanupHook {
|
||||||
|
|
||||||
|
private static final Logger LOG =
|
||||||
|
getLogger(MessagingManagerImpl.class.getName());
|
||||||
|
|
||||||
private final DatabaseComponent db;
|
private final DatabaseComponent db;
|
||||||
private final ClientHelper clientHelper;
|
private final ClientHelper clientHelper;
|
||||||
private final MetadataParser metadataParser;
|
private final MetadataParser metadataParser;
|
||||||
@@ -201,6 +208,7 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
|
|||||||
private void incomingPrivateMessage(Transaction txn, Message m,
|
private void incomingPrivateMessage(Transaction txn, Message m,
|
||||||
BdfDictionary meta, boolean hasText, List<AttachmentHeader> headers)
|
BdfDictionary meta, boolean hasText, List<AttachmentHeader> headers)
|
||||||
throws DbException, FormatException {
|
throws DbException, FormatException {
|
||||||
|
long start = now();
|
||||||
GroupId groupId = m.getGroupId();
|
GroupId groupId = m.getGroupId();
|
||||||
long timestamp = meta.getLong(MSG_KEY_TIMESTAMP);
|
long timestamp = meta.getLong(MSG_KEY_TIMESTAMP);
|
||||||
boolean local = meta.getBoolean(MSG_KEY_LOCAL);
|
boolean local = meta.getBoolean(MSG_KEY_LOCAL);
|
||||||
@@ -221,6 +229,7 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
|
|||||||
autoDeleteManager.receiveAutoDeleteTimer(txn, contactId, timer,
|
autoDeleteManager.receiveAutoDeleteTimer(txn, contactId, timer,
|
||||||
timestamp);
|
timestamp);
|
||||||
if (!headers.isEmpty()) stopAttachmentCleanupTimers(txn, m, headers);
|
if (!headers.isEmpty()) stopAttachmentCleanupTimers(txn, m, headers);
|
||||||
|
logDuration(LOG, "Receiving private message", start);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<AttachmentHeader> parseAttachmentHeaders(GroupId g,
|
private List<AttachmentHeader> parseAttachmentHeaders(GroupId g,
|
||||||
@@ -256,6 +265,7 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
|
|||||||
|
|
||||||
private void incomingAttachment(Transaction txn, Message m)
|
private void incomingAttachment(Transaction txn, Message m)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
|
long start = now();
|
||||||
ContactId contactId = getContactId(txn, m.getGroupId());
|
ContactId contactId = getContactId(txn, m.getGroupId());
|
||||||
txn.attach(new AttachmentReceivedEvent(m.getId(), contactId));
|
txn.attach(new AttachmentReceivedEvent(m.getId(), contactId));
|
||||||
// If no private messages that list this attachment have been
|
// If no private messages that list this attachment have been
|
||||||
@@ -281,6 +291,7 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
|
|||||||
} catch (FormatException e) {
|
} catch (FormatException e) {
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
}
|
}
|
||||||
|
logDuration(LOG, "Receiving attachment", start);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user