-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1471 from Zimbra/bugfix/ZCS-7111
ZCS-7111: Optimize index data size by "delayed indexing"
- Loading branch information
Showing
12 changed files
with
508 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
soap/src/java/com/zimbra/soap/admin/message/ManageIndexRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* ***** BEGIN LICENSE BLOCK ***** | ||
* Zimbra Collaboration Suite Server | ||
* Copyright (C) 2023 Synacor, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software Foundation, | ||
* version 2 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License along with this program. | ||
* If not, see <https://www.gnu.org/licenses/>. | ||
* ***** END LICENSE BLOCK ***** | ||
*/ | ||
|
||
package com.zimbra.soap.admin.message; | ||
|
||
import javax.xml.bind.annotation.XmlAccessType; | ||
import javax.xml.bind.annotation.XmlAccessorType; | ||
import javax.xml.bind.annotation.XmlAttribute; | ||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
|
||
import com.zimbra.common.soap.AdminConstants; | ||
import com.zimbra.soap.admin.type.MailboxByAccountIdSelector; | ||
|
||
/** | ||
* @zm-api-command-auth-required true | ||
* @zm-api-command-admin-auth-required true | ||
* @zm-api-command-description Manage index for Delayed Index feature. When disableIndexing is specified, | ||
* zimbraFeatureDelayedIndexEnabled is set to TRUE, zimbraDelayedIndexStatus is set to suppressed, and index data | ||
* except Contacts is removed. When enableIndexing is specified, zimbraDelayedIndexStatus is set to indexing and | ||
* index data is created. | ||
* <br /> | ||
* <b>Access</b>: domain admin sufficient | ||
* <br /> | ||
* note: this request is by default proxied to the account's home server | ||
*/ | ||
@XmlAccessorType(XmlAccessType.NONE) | ||
@XmlRootElement(name=AdminConstants.E_MANAGE_INDEX_REQUEST) | ||
public class ManageIndexRequest { | ||
|
||
/** | ||
* @zm-api-field-description Specify mailbox to manage | ||
*/ | ||
@XmlElement(name=AdminConstants.E_MAILBOX, required=true) | ||
private final MailboxByAccountIdSelector mbox; | ||
|
||
/** | ||
* @zm-api-field-tag "disableIndexing|enableIndexing" | ||
* @zm-api-field-description Action to perform | ||
* <table> | ||
* <tr> <td> <b>disableIndexing</b> </td> <td> disable indexing and delete index </td> </tr> | ||
* <tr> <td> <b>enableIndexing</b> </td> <td> enable indexing and create index </td> </tr> | ||
* </table> | ||
*/ | ||
@XmlAttribute(name=AdminConstants.E_ACTION, required=true) | ||
private final String action; | ||
|
||
/** | ||
* no-argument constructor wanted by JAXB | ||
*/ | ||
@SuppressWarnings("unused") | ||
private ManageIndexRequest() { | ||
this((String)null, (MailboxByAccountIdSelector)null); | ||
} | ||
|
||
public ManageIndexRequest(String action, MailboxByAccountIdSelector mbox) { | ||
this.action = action; | ||
this.mbox = mbox; | ||
} | ||
|
||
public String getAction() { return action; } | ||
public MailboxByAccountIdSelector getMbox() { return mbox; } | ||
} |
51 changes: 51 additions & 0 deletions
51
soap/src/java/com/zimbra/soap/admin/message/ManageIndexResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* ***** BEGIN LICENSE BLOCK ***** | ||
* Zimbra Collaboration Suite Server | ||
* Copyright (C) 2023 Synacor, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software Foundation, | ||
* version 2 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License along with this program. | ||
* If not, see <https://www.gnu.org/licenses/>. | ||
* ***** END LICENSE BLOCK ***** | ||
*/ | ||
|
||
package com.zimbra.soap.admin.message; | ||
|
||
import javax.xml.bind.annotation.XmlAccessType; | ||
import javax.xml.bind.annotation.XmlAccessorType; | ||
import javax.xml.bind.annotation.XmlAttribute; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
|
||
import com.zimbra.common.soap.AdminConstants; | ||
|
||
@XmlAccessorType(XmlAccessType.NONE) | ||
@XmlRootElement(name=AdminConstants.E_MANAGE_INDEX_RESPONSE) | ||
public class ManageIndexResponse { | ||
|
||
/** | ||
* @zm-api-field-tag status | ||
* @zm-api-field-description <b>started</b> when action is accepted | ||
*/ | ||
@XmlAttribute(name=AdminConstants.A_STATUS, required=true) | ||
private final String status; | ||
|
||
/** | ||
* no-argument constructor wanted by JAXB | ||
*/ | ||
@SuppressWarnings("unused") | ||
private ManageIndexResponse() { | ||
this((String)null); | ||
} | ||
|
||
public ManageIndexResponse(String status) { | ||
this.status = status; | ||
} | ||
|
||
public String getStatus() { return status; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
store/src/java-test/com/zimbra/cs/mailbox/MailboxIndexTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* ***** BEGIN LICENSE BLOCK ***** | ||
* Zimbra Collaboration Suite Server | ||
* Copyright (C) 2023 Synacor, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software Foundation, | ||
* version 2 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License along with this program. | ||
* If not, see <https://www.gnu.org/licenses/>. | ||
* ***** END LICENSE BLOCK ***** | ||
*/ | ||
package com.zimbra.cs.mailbox; | ||
|
||
import java.util.HashMap; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import com.zimbra.common.account.ZAttrProvisioning.DelayedIndexStatus; | ||
import com.zimbra.cs.account.Account; | ||
import com.zimbra.cs.account.Provisioning; | ||
|
||
/** | ||
* Unit test for {@link Folder}. | ||
*/ | ||
public final class MailboxIndexTest { | ||
|
||
@BeforeClass | ||
public static void init() throws Exception { | ||
MailboxTestUtil.initServer(); | ||
Provisioning prov = Provisioning.getInstance(); | ||
prov.createAccount("[email protected]", "secret", new HashMap<String, Object>()); | ||
} | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
MailboxTestUtil.clearData(); | ||
} | ||
|
||
@Test | ||
public void needToReIndexTest() throws Exception { | ||
Account acct = Provisioning.getInstance().getAccountByName("[email protected]"); | ||
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(acct); | ||
MailboxIndex index = mbox.index; | ||
index.deleteIndex(); | ||
acct.setFeatureMobileSyncEnabled(false); | ||
|
||
acct.unsetFeatureDelayedIndexEnabled(); | ||
acct.unsetDelayedIndexStatus(); | ||
Assert.assertTrue("zimbraFeatureDelayedIndexEnabled is unset and zimbraDelayedIndex is unset", index.needToReIndex()); | ||
|
||
acct.setDelayedIndexStatus(DelayedIndexStatus.suppressed); | ||
Assert.assertTrue("zimbraFeatureDelayedIndexEnabled is unset and zimbraDelayedIndex is suppressed", index.needToReIndex()); | ||
|
||
acct.setDelayedIndexStatus(DelayedIndexStatus.waitingForSearch); | ||
Assert.assertTrue("zimbraFeatureDelayedIndexEnabled is unset and zimbraDelayedIndex is waitingForSearch", index.needToReIndex()); | ||
|
||
acct.setDelayedIndexStatus(DelayedIndexStatus.indexing); | ||
Assert.assertTrue("zimbraFeatureDelayedIndexEnabled is unset and zimbraDelayedIndex is indexing", index.needToReIndex()); | ||
|
||
acct.setFeatureDelayedIndexEnabled(false); | ||
acct.unsetDelayedIndexStatus(); | ||
Assert.assertTrue("zimbraFeatureDelayedIndexEnabled is FALSE and zimbraDelayedIndex is unset", index.needToReIndex()); | ||
|
||
acct.setDelayedIndexStatus(DelayedIndexStatus.suppressed); | ||
Assert.assertTrue("zimbraFeatureDelayedIndexEnabled is FALSE and zimbraDelayedIndex is suppressed", index.needToReIndex()); | ||
|
||
acct.setDelayedIndexStatus(DelayedIndexStatus.waitingForSearch); | ||
Assert.assertTrue("zimbraFeatureDelayedIndexEnabled is FALSE and zimbraDelayedIndex is waitingForSearch", index.needToReIndex()); | ||
|
||
acct.setDelayedIndexStatus(DelayedIndexStatus.indexing); | ||
Assert.assertTrue("zimbraFeatureDelayedIndexEnabled is FALSE and zimbraDelayedIndex is indexing", index.needToReIndex()); | ||
|
||
acct.setFeatureDelayedIndexEnabled(true); | ||
acct.unsetDelayedIndexStatus(); | ||
Assert.assertFalse("zimbraFeatureDelayedIndexEnabled is TRUE and zimbraDelayedIndex is unset", index.needToReIndex()); | ||
|
||
acct.setDelayedIndexStatus(DelayedIndexStatus.suppressed); | ||
Assert.assertFalse("zimbraFeatureDelayedIndexEnabled is TRUE and zimbraDelayedIndex is suppressed", index.needToReIndex()); | ||
|
||
acct.setDelayedIndexStatus(DelayedIndexStatus.waitingForSearch); | ||
Assert.assertTrue("zimbraFeatureDelayedIndexEnabled is TRUE and zimbraDelayedIndex is waitingForSearch", index.needToReIndex()); | ||
|
||
acct.setDelayedIndexStatus(DelayedIndexStatus.indexing); | ||
Assert.assertFalse("zimbraFeatureDelayedIndexEnabled is TRUE and zimbraDelayedIndex is indexing", index.needToReIndex()); | ||
|
||
acct.setFeatureMobileSyncEnabled(true); | ||
Assert.assertFalse("zimbraFeatureDelayedIndexEnabled is TRUE, zimbraDelayedIndex is indexing and " + | ||
"zimbraFeatureMobileSyncEnabled is TRUE, but not Mobile Sync Access", index.needToReIndex()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.