Search in sources :

Example 26 with Blob

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

the class StoreIncomingBlob method redo.

@Override
public void redo() throws Exception {
    // Execution of redo is logged to current redo logger.  For most other
    // ops this is handled by Mailbox class, but StoreIncomingBlob is an
    // exception because of the way it is used in Mailbox.
    StoreIncomingBlob redoRecorder = null;
    if (!getUnloggedReplay()) {
        redoRecorder = new StoreIncomingBlob(mDigest, mMsgSize, mMailboxIdList);
        redoRecorder.start(getTimestamp());
        redoRecorder.setBlobBodyInfo(new RedoableOpDataSource(mData), mData.getLength(), mPath);
        redoRecorder.log();
    }
    boolean success = false;
    try {
        boolean compressed = mData.getLength() != mMsgSize;
        Blob blob = StoreManager.getInstance().storeIncoming(mData.getInputStream(), compressed);
        if (compressed) {
            blob.setDigest(mDigest).setRawSize(mMsgSize).setCompressed(compressed);
        }
        registerBlob(mPath, blob);
        success = true;
    } finally {
        if (redoRecorder != null) {
            if (success) {
                redoRecorder.commit();
            } else {
                redoRecorder.abort();
            }
        }
    }
}
Also used : Blob(com.zimbra.cs.store.Blob)

Example 27 with Blob

use of com.zimbra.cs.store.Blob 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

Blob (com.zimbra.cs.store.Blob)27 MailboxBlob (com.zimbra.cs.store.MailboxBlob)18 Mailbox (com.zimbra.cs.mailbox.Mailbox)14 StagedBlob (com.zimbra.cs.store.StagedBlob)13 ParsedMessage (com.zimbra.cs.mime.ParsedMessage)12 IOException (java.io.IOException)11 StoreManager (com.zimbra.cs.store.StoreManager)10 ServiceException (com.zimbra.common.service.ServiceException)9 InputStream (java.io.InputStream)7 Test (org.junit.Test)6 MailServiceException (com.zimbra.cs.mailbox.MailServiceException)5 NoSuchItemException (com.zimbra.cs.mailbox.MailServiceException.NoSuchItemException)4 StoreIncomingBlob (com.zimbra.cs.redolog.op.StoreIncomingBlob)4 Rfc822ValidationInputStream (com.zimbra.common.mime.Rfc822ValidationInputStream)3 CopyInputStream (com.zimbra.common.util.CopyInputStream)3 AccountServiceException (com.zimbra.cs.account.AccountServiceException)3 DeliveryContext (com.zimbra.cs.mailbox.DeliveryContext)3 ParsedMessageOptions (com.zimbra.cs.mime.ParsedMessageOptions)3 AbstractStoreManagerTest (com.zimbra.cs.store.AbstractStoreManagerTest)3 BlobInputStream (com.zimbra.cs.store.BlobInputStream)3