use of com.zimbra.cs.index.elasticsearch.ElasticSearchIndex in project zm-mailbox by Zimbra.
the class MailboxTestUtil method cleanupIndexStore.
public static void cleanupIndexStore(Mailbox mbox) {
IndexStore index = mbox.index.getIndexStore();
if (index instanceof ElasticSearchIndex) {
String key = mbox.getAccountId();
String indexUrl = String.format("%s%s/", LC.zimbra_index_elasticsearch_url_base.value(), key);
HttpMethod method = new DeleteMethod(indexUrl);
try {
ElasticSearchConnector connector = new ElasticSearchConnector();
int statusCode = connector.executeMethod(method);
if (statusCode == HttpStatus.SC_OK) {
boolean ok = connector.getBooleanAtJsonPath(new String[] { "ok" }, false);
boolean acknowledged = connector.getBooleanAtJsonPath(new String[] { "acknowledged" }, false);
if (!ok || !acknowledged) {
ZimbraLog.index.debug("Delete index status ok=%b acknowledged=%b", ok, acknowledged);
}
} else {
String error = connector.getStringAtJsonPath(new String[] { "error" });
if (error != null && error.startsWith("IndexMissingException")) {
ZimbraLog.index.debug("Unable to delete index for key=%s. Index is missing", key);
} else {
ZimbraLog.index.error("Problem deleting index for key=%s error=%s", key, error);
}
}
} catch (HttpException e) {
ZimbraLog.index.error("Problem Deleting index with key=" + key, e);
} catch (IOException e) {
ZimbraLog.index.error("Problem Deleting index with key=" + key, e);
}
}
}
Aggregations