use of com.zimbra.cs.volume.Volume in project zm-mailbox by Zimbra.
the class FileBlobStore method getUniqueIncomingBlob.
private Blob getUniqueIncomingBlob() throws IOException, ServiceException {
Volume volume = MANAGER.getCurrentMessageVolume();
IncomingDirectory incdir = volume.getIncomingDirectory();
if (incdir == null) {
throw ServiceException.FAILURE("storing blob to volume without incoming directory: " + volume.getName(), null);
}
File f = incdir.getNewIncomingFile();
ensureParentDirExists(f);
return new VolumeBlob(f, volume.getId());
}
use of com.zimbra.cs.volume.Volume in project zm-mailbox by Zimbra.
the class DbVolumeBlobsTest method testUniqueBlobDigests.
@Test
public void testUniqueBlobDigests() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
DeliveryOptions opt = new DeliveryOptions();
opt.setFolderId(Mailbox.ID_FOLDER_INBOX);
Volume vol = VolumeManager.getInstance().getCurrentMessageVolume();
for (int i = 0; i < 5; i++) {
mbox.addMessage(null, new ParsedMessage(("From: from" + i + "@zimbra.com\r\nTo: to1@zimbra.com").getBytes(), false), opt, null);
mbox.addMessage(null, new ParsedMessage(("From: from" + i + "@zimbra.com\r\nTo: to1@zimbra.com").getBytes(), false), opt, null);
}
Iterable<MailboxBlobInfo> allBlobs = null;
allBlobs = DbMailItem.getAllBlobs(conn, mbox.getSchemaGroupId(), vol.getId(), -1, -1);
for (MailboxBlobInfo info : allBlobs) {
DbVolumeBlobs.addBlobReference(conn, info);
}
SpoolingCache<String> digests = DbVolumeBlobs.getUniqueDigests(conn, vol);
Assert.assertEquals(5, digests.size());
}
use of com.zimbra.cs.volume.Volume in project zm-mailbox by Zimbra.
the class DbVolumeBlobsTest method testDuplicateRow.
@Test
public void testDuplicateRow() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
DeliveryOptions opt = new DeliveryOptions();
opt.setFolderId(Mailbox.ID_FOLDER_INBOX);
Message msg = mbox.addMessage(null, new ParsedMessage("From: from1@zimbra.com\r\nTo: to1@zimbra.com".getBytes(), false), opt, null);
Volume vol = VolumeManager.getInstance().getCurrentMessageVolume();
MailboxBlobInfo blobInfo = new MailboxBlobInfo(null, mbox.getId(), msg.getId(), msg.getSavedSequence(), String.valueOf(vol.getId()), null);
DbVolumeBlobs.addBlobReference(conn, blobInfo);
try {
DbVolumeBlobs.addBlobReference(conn, blobInfo);
Assert.fail("expected exception");
} catch (ServiceException e) {
// expected
}
}
use of com.zimbra.cs.volume.Volume in project zm-mailbox by Zimbra.
the class TestBlobDeduper method testBlobDeduper.
@Test
public void testBlobDeduper() throws Exception {
Assume.assumeTrue(StoreManager.getInstance() instanceof FileBlobStore);
DeliveryOptions opt = new DeliveryOptions();
opt.setFolderId(Mailbox.ID_FOLDER_INBOX);
String[] paths = new String[5];
Volume vol = VolumeManager.getInstance().getCurrentMessageVolume();
for (int i = 0; i < 5; i++) {
Message msg = mbox.addMessage(null, new ParsedMessage(("From: test@zimbra.com\r\nTo: to1@zimbra.com\r\nSubject: " + TEST_NAME).getBytes(), false), opt, null);
paths[i] = msg.getBlob().getLocalBlob().getFile().getPath();
}
// Make sure inodes are different for paths
for (int i = 0; i < 4; i++) {
Assert.assertFalse(IO.fileInfo(paths[i]).getInodeNum() == IO.fileInfo(paths[i + 1]).getInodeNum());
}
// wait for a seconds, so that timestamp gets changed.
Thread.sleep(1000);
BlobDeduper deduper = BlobDeduper.getInstance();
List<Short> volumeIds = new ArrayList<Short>();
volumeIds.add(vol.getId());
deduper.process(volumeIds);
while (deduper.isRunning()) {
// wait until deduper finishes.
Thread.sleep(1000);
}
// Make sure inodes are same for paths
for (int i = 0; i < 4; i++) {
Assert.assertTrue(IO.fileInfo(paths[i]).getInodeNum() == IO.fileInfo(paths[i + 1]).getInodeNum());
}
}
use of com.zimbra.cs.volume.Volume in project zm-mailbox by Zimbra.
the class TestDocumentServer method setUp.
@Before
public void setUp() throws Exception {
String prefix = NAME_PREFIX + "-" + testInfo.getMethodName() + "-";
USER_NAME = prefix + "user";
cleanUp();
TestUtil.createAccount(USER_NAME);
Volume vol = VolumeManager.getInstance().getCurrentMessageVolume();
mOriginalCompressBlobs = vol.isCompressBlobs();
mOriginalCompressionThreshold = vol.getCompressionThreshold();
}
Aggregations