Search in sources :

Example 21 with StagedBlob

use of com.zimbra.cs.store.StagedBlob in project zm-mailbox by Zimbra.

the class VerifyStoreManager method basicPerfTest.

private Stats basicPerfTest(int numBlobs, int blobSize, boolean checkBlobs) throws Exception {
    Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(AccountTestUtil.getAccount(USER_NAME));
    StoreManager sm = StoreManager.getInstance();
    List<ParsedMessage> msgs = new ArrayList<ParsedMessage>();
    int count = numBlobs;
    for (int i = 0; i < count; i++) {
        msgs.add(getMessage(blobSize));
    }
    List<Blob> incoming = new ArrayList<Blob>();
    ZimbraLog.store.info("starting store incoming loop");
    long start = System.currentTimeMillis();
    for (ParsedMessage msg : msgs) {
        incoming.add(sm.storeIncoming(msg.getRawInputStream()));
    }
    long incomingTime = System.currentTimeMillis() - start;
    List<StagedBlob> staged = new ArrayList<StagedBlob>();
    ZimbraLog.store.info("starting stage loop");
    start = System.currentTimeMillis();
    for (Blob blob : incoming) {
        staged.add(sm.stage(blob, mbox));
    }
    long stageTime = System.currentTimeMillis() - start;
    List<MailboxBlob> linked = new ArrayList<MailboxBlob>();
    ZimbraLog.store.info("starting link loop");
    start = System.currentTimeMillis();
    //fake itemId, never use this test with real userid
    int i = 0;
    for (StagedBlob blob : staged) {
        linked.add(sm.link(blob, mbox, i++, 1));
    }
    long linkTime = System.currentTimeMillis() - start;
    List<MailboxBlob> fetched = new ArrayList<MailboxBlob>();
    ZimbraLog.store.info("starting fetch loop");
    start = System.currentTimeMillis();
    i = 0;
    for (MailboxBlob mblob : linked) {
        fetched.add(sm.getMailboxBlob(mbox, i++, 1, mblob.getLocator()));
    }
    long fetchTime = System.currentTimeMillis() - start;
    if (checkBlobs) {
        for (i = 0; i < count; i++) {
            checkBlob(msgs.get(i), incoming.get(i), staged.get(i), linked.get(i), fetched.get(i), mbox);
        }
    }
    ZimbraLog.store.info("starting delete loop");
    start = System.currentTimeMillis();
    for (MailboxBlob mblob : fetched) {
        sm.delete(mblob);
    }
    long deleteTime = System.currentTimeMillis() - start;
    Stats stats = new Stats(numBlobs, incomingTime, stageTime, linkTime, fetchTime, deleteTime);
    return stats;
}
Also used : Blob(com.zimbra.cs.store.Blob) MailboxBlob(com.zimbra.cs.store.MailboxBlob) StagedBlob(com.zimbra.cs.store.StagedBlob) StagedBlob(com.zimbra.cs.store.StagedBlob) MailboxBlob(com.zimbra.cs.store.MailboxBlob) ParsedMessage(com.zimbra.cs.mime.ParsedMessage) ArrayList(java.util.ArrayList) StoreManager(com.zimbra.cs.store.StoreManager) Mailbox(com.zimbra.cs.mailbox.Mailbox)

Aggregations

StagedBlob (com.zimbra.cs.store.StagedBlob)21 MailboxBlob (com.zimbra.cs.store.MailboxBlob)15 StoreManager (com.zimbra.cs.store.StoreManager)15 Blob (com.zimbra.cs.store.Blob)11 InputStream (java.io.InputStream)11 Mailbox (com.zimbra.cs.mailbox.Mailbox)8 ParsedMessage (com.zimbra.cs.mime.ParsedMessage)8 IOException (java.io.IOException)8 Rfc822ValidationInputStream (com.zimbra.common.mime.Rfc822ValidationInputStream)6 CopyInputStream (com.zimbra.common.util.CopyInputStream)6 TargetConstraint (com.zimbra.cs.mailbox.MailItem.TargetConstraint)6 CreateMountpoint (com.zimbra.cs.redolog.op.CreateMountpoint)6 RefreshMountpoint (com.zimbra.cs.redolog.op.RefreshMountpoint)6 Test (org.junit.Test)6 ServiceException (com.zimbra.common.service.ServiceException)3 AccountServiceException (com.zimbra.cs.account.AccountServiceException)3 DbTag (com.zimbra.cs.db.DbTag)3 NormalizedTags (com.zimbra.cs.mailbox.Tag.NormalizedTags)3 ParsedMessageDataSource (com.zimbra.cs.mime.ParsedMessageDataSource)3 AlterItemTag (com.zimbra.cs.redolog.op.AlterItemTag)3