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