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();
}
}
}
}
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;
}
Aggregations