use of com.zimbra.cs.index.elasticsearch.ElasticSearchConnector in project zm-mailbox by Zimbra.
the class ElasticSearchIndexTest method indexStoreAvailable.
@Override
protected boolean indexStoreAvailable() {
String indexUrl = String.format("%s?_status", LC.zimbra_index_elasticsearch_url_base.value());
HttpMethod method = new GetMethod(indexUrl);
try {
ElasticSearchConnector connector = new ElasticSearchConnector();
connector.executeMethod(method);
} catch (HttpException e) {
ZimbraLog.index.error("Problem accessing the ElasticSearch Index store", e);
return false;
} catch (IOException e) {
ZimbraLog.index.error("Problem accessing the ElasticSearch Index store", e);
return false;
}
return true;
}
use of com.zimbra.cs.index.elasticsearch.ElasticSearchConnector in project zm-mailbox by Zimbra.
the class ElasticSearchIndexTest method cleanupForIndexStore.
@Override
protected void cleanupForIndexStore() {
String key = testAcct.getId();
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);
}
}
use of com.zimbra.cs.index.elasticsearch.ElasticSearchConnector 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